A simple php RESTful api wrapper.
$restful = new RESTful('https://<yourcompany>.com/<path>/<to>/<resource>', '<token>');
$restful->post($path, $data);
The default Content-Type is application/json
To change the default Content-Type
$restful->setContentType(<newContentType>);
The default URL Path is <baseURI>/<paht_to_data>/<token>/
If you need to add a special configuration to the URL path
$restful->setPathConfiguration(<newPathConfiguration>);
Firebase needs a .json?auth=
format.
$restful = new RESTful('https://<yourcompany>.com/<path>/<to>/<resource>', '<token>');
$restful->setPathConfiguration('.json?auth=');
$restful->post($path, $data);
To set the authentication in the header request
$restful->setHeaderProperty('<name_of_property>');
The full header property will be
'<name_of_property>: <token>'
delete($path)
get($path)
getHeaderLocation()
getHeaderResponseCode()
getResponseBody()
patch($path, $data)
post($path, $data)
put($path, $data)
setBaseURI($baseURI)
setContentType($contentType)
setHeaderProperty($headerProperty)
setPathConfiguration($pathConfiguration)
setTimeOut($seconds)
setToken($token)
All the unit tests are found in the "/tests" directory.
The RESTful tests can be executed by running the following command:
$ phpunit
$ phpunit --group <groupName>
$ phpunit tests/unit/<file_name.php>
I started with the firebase-php library (https://github.com/ktamas77/firebase-php). Tamas' code is simply amazing! I helped him write the tests and the test stub. I reached out to him to fork and abstract the code but I never received a response.
https://github.com/ktamas77/firebase-php @author Tamas Kalman [email protected]