Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Jul 15, 2016
0 parents commit 414e0f9
Show file tree
Hide file tree
Showing 43 changed files with 1,801 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab

[.travis.yml]
indent_size = 2
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.php diff=php

/tests export-ignore

/phpunit.xml.dist export-ignore

/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs export-ignore


8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/build
/vendor
/docs/_build
/docs/*.pyc

/composer.lock
/phpunit.xml
/google-service-account.json
28 changes: 28 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$header = '';

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers([
'header_comment',
'multiline_spaces_before_semicolon',
'newline_after_open_tag',
'ordered_use',
'phpdoc_order',
'short_array_syntax',
'strict',
'strict_param',
'unalign_double_arrow',
'unalign_equals',
'unused_use',
])
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->exclude('vendor')
->exclude('build')
->in(__DIR__)
)
;
111 changes: 111 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# CHANGELOG

## 0.10.1 - 2016-07-03

* Added support for authentication with a Google Service account

## 0.10.0 - 2016-04-28

* Added magic getters, allowing to write `$firebase->foo` instead of instead of `$firebase->getReference('foo')`
* Deprecated magic callers to allow writing `$firebase->foo()`

## 0.9.1 - 2016-03-18

* Added magic reference methods, to allow writing `$firebase->foo()`
instead of `$firebase->getReference('foo')`

## 0.9 - 2015-12-07

* Added support for shallow queries (thanks to [@famersbs](https://github.com/famersbs) for the initial
implementation in [#17](https://github.com/kreait/firebase-php/pull/17))

## 0.8 - 2015-12-07

* Allow usage of phpunit/phpunit ^5.0
* Allow usage of symfony/event-dispatcher ^3.0
* Be more specific about PHP versions (^5.5|^7.0)

## 0.7 - 2015-08-13

* Update Ivory HTTP Adapter and Tape Recorder Subscriber to current versions.

## 0.6.2 - 2015-05-04

* Guess best HTTP adapter instead of using fixed CurlHttpAdapter.

## 0.6.1 - 2015-04-17

* Fixed a bug where `Reference::update()` would throw an error with multidimensional data.

## 0.6 - 2015-04-12

* Added Authentication support
* Ensure PHP7 and HHVM support
* Improved tests and general code quality

## 0.5 - 2015-04-02

* Use `Configuration` object instead of configuring `Firebase` directly.

## 0.4.2 - 2015-03-25

* Fix Query documentation
* Use Tape Recorder Subscriber for Reference Tests
* Make sure data returned from Firebase is an array (null responses weren't handled correctly)

## 0.4.1 - 2015-02-23

* Use Tape Recorder Subscriber as distinct package instead of relying on the PR branch of the Ivory HTTP Adapter.

## 0.4.0 - 2015-02-10

* Use TapeRecorder subscriber in HTTP adapter to use fixtures instead of real HTTP requests.
* Use [dotenv](https://github.com/vlucas/phpdotenv/) for the test environment.
* Moved `FirebaseException` to own namespace.
* Add support for Queries.

## 0.3.1 - 2015-01-27

* Bugfix: Allow whitespaces in locations

## 0.3 - 2015-01-27

* **Breaking changes: References have changed behaviour**
* `Reference` doesn't extend `Firebase` anymore and has changed behaviour (see the [doc/02-references.md](documentation about References)).
* Reference data can be accessed with `$reference->getData()`, which returns an array, or directly with `$reference['key']`.
* Reference data can be updated with `$reference->update(['key' => 'value'])` or with `$reference['key'] = 'value'`.
* Improved test coverage.
* Added Makefile to ease test execution.
* Extended documentation and moved in to the doc folder.

## 0.2.4 - 2015-01-21

* Add `ext-mbstring` as a requirement in `composer.json`
* Improved test coverage and added badges to README to show it off :)

## 0.2.3 - 2015-01-20

Fixed an error where the throw of an exception would throw an exception because of a wrong usage of `sprintf()`

## 0.2.2 - 2015-01-20

Fixed a case where an exception would be thrown inside an exception when no response was present.

## 0.2.1 - 2015-01-19

The Firebase library now has its own base URL handling so that a stable version of the HTTP adapter can be used.

## 0.2 - 2015-01-13

* Better handling of server errors: Instead of using hard coded exception messages for assumed server errors, a single server error exception now includes the server's error message, if available.
* It is now possible to use the `shallow` parameter when performing a GET request. See [the Firebase Docs on Query Parameters](https://www.firebase.com/docs/rest/api/#section-query-parameters) for a detailed description.
* `Firebase::push()` now returns the generated key as a string (not as an array `['name' => '...']`) anymore

## 0.1.1 - 2015-01-09

* The logger output now is less verbose and includes full URLs
* The README now includes an usage example

## 0.1 - 2015-01-09

Initial release
65 changes: 65 additions & 0 deletions Firebase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Kreait;

use Kreait\Firebase\Database;
use Kreait\Firebase\Google;
use Kreait\Firebase\Http;
use Kreait\Firebase\Http\Auth;
use Kreait\Firebase\Storage;
use League\Flysystem\Filesystem;

final class Firebase
{
private $serviceAccount;
private $httpFactory;
private $storageFactory;

private $storage;
private $database;


public function __construct(
Google\ServiceAccount $serviceAccount,
Http\Factory $httpFactory = null,
Storage\Factory $storageFactory = null
) {
$this->serviceAccount = $serviceAccount;
$this->httpFactory = $httpFactory ?? new Http\Factory($serviceAccount);
$this->storageFactory = $storageFactory ?? new Storage\Factory($serviceAccount);
}

public static function create($serviceAccount): self
{
$serviceAccount = Google\ServiceAccount::createWith($serviceAccount);
return new self($serviceAccount);
}

public function getStorage(): Filesystem
{
if (!$this->storage) {
$this->storage = $this->storageFactory->createGoogleStorageFilesystem();
}

return $this->storage;
}

public function getDatabase(): Database
{
if (!$this->database) {
$this->database = new Database($this->httpFactory->createDatabaseClient());
}

return $this->database;
}

public function withAuthOverride(Auth $auth): self
{
$new = new self($this->serviceAccount, $this->httpFactory, $this->storageFactory);

$new->storage = $this->storageFactory->createGoogleStorageFilesystem($auth);
$new->database = new Database($this->httpFactory->createDatabaseClient($auth));

return $new;
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Jérôme Gamez, https://github.com/jeromegamez <jerome@gamez.name>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Firebase PHP SDK

A PHP SDK for [Google Firebase](https://firebase.google.com)

**Version 2.0 is under heavy development, please use Version 1.0 for now**

---

Documentation: http://firebase-php.readthedocs.io
47 changes: 47 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "kreait/firebase",
"description": "PHP SDK for Google Firebase",
"keywords": ["firebase", "google", "sdk", "api", "database"],
"homepage": "https://github.com/kreait/firebase-php",
"license": "MIT",
"authors": [
{
"name": "Jérôme Gamez",
"homepage": "https://github.com/jeromegamez"
}
],
"require": {
"php": "^7.0",
"google/apiclient": "^2.0",
"guzzlehttp/guzzle": "^6.0",
"league/flysystem": "^1.0",
"superbalist/flysystem-google-storage": "^2.0@beta"
},
"require-dev": {
"phpunit/phpunit": "^5.4"
},
"autoload": {
"psr-4": {
"Kreait\\Firebase\\": "src"
},
"files": [
"Firebase.php"
]
},
"autoload-dev": {
"psr-4": {
"Kreait\\Tests\\Firebase\\": "tests"
}
},
"config": {
"platform": {
"php": "7.0"
}
},
"extra": {
"branch-alias": {
"dev-1.0": "1.x-dev",
"dev-2.0": "2.x-dev"
}
}
}

0 comments on commit 414e0f9

Please sign in to comment.