https://github.com/jbroadway/phpactiveresource
A PHP client library for easily accessing Ruby on Rails-based REST services
https://github.com/jbroadway/phpactiveresource
Last synced: 9 months ago
JSON representation
A PHP client library for easily accessing Ruby on Rails-based REST services
- Host: GitHub
- URL: https://github.com/jbroadway/phpactiveresource
- Owner: jbroadway
- License: mit
- Created: 2009-04-16T07:19:30.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2019-03-05T22:46:15.000Z (almost 7 years ago)
- Last Synced: 2025-04-06T19:59:22.337Z (10 months ago)
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 116
- Watchers: 8
- Forks: 27
- Open Issues: 1
-
Metadata Files:
- Readme: README.textile
- License: LICENSE
Awesome Lists containing this project
README
h1. PHP ActiveResource
This is a PHP class for accessing Ruby on Rails REST APIs in an ActiveResource style of coding. The benefit is easier use of RoR-based REST services without having to roll your own CURL-based client each time. Hopefully this class saves a few people some time coding in PHP against RoR-based REST services. It's by no means an exhaustive port, and some methods are missing, but it does try to cover all the basics.
Note: You will need the php curl extension installed on your system. On Ubuntu, you can install it via:
sudo apt-get install php5-curl
h2. Usage
h3. With Composer
Create a composer.json file with the following:
{
"require": {
"phpactiveresource/phpactiveresource": "dev-master"
}
}
Now load the script via Composer's autoloader:
h3. Without Composer
'Joe Cocker', 'title' => 'A Little Help From My Friends'));
$song->save ();
// fetch and update an item, chaining statements
$song->find (44)->set ('title', 'The River')->save ();
// fetch and update, line by line
$song->find (44);
$song->title = 'The River';
$song->save ();
// get all songs
$songs = $song->find ('all');
// delete a song
$song->find (44);
$song->destroy ();
// custom method
$songs = $song->get ('by_year', array ('year' => 1999));
?>
h2. Extra URL params
If you want to add extra params to the end of the url eg: an API key, you can set $extra_params
h2. Extra Http Headers
If you need to add extra http request headers you can set $request_headers
See the Github Wiki pages for more examples and documentation.
