Skip to content
Generic RESTful Service - Eases the implementation of a service layer using REST.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Generic RESTful Service

Welcome to Grs

This project aims to ease the implementation of a service layer using REST.

Make sure to configure your environment by listing the parent directories for Grs on include_path (php.ini). This project depends on URL rewrite (mod_rewrite).

How you use it:

To create a REST service on some context (an arbitrary directory inside web root):

simply create a .htacess on context's real path like this:


<fModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . grs.php [L]

and, in the same directory, the grs.php stated on RewriteRule, above:


require 'Grs/Grs.php';
$grs = new \Nexy\Grs();

change $grs->setModelsPath to reflect your model classes path, and that's it!


which will result in:

1. Require a file called Class1.php which should reside in my/model/path.
2. Instantiate an object of Class1
3. Call a method named method1 from the newly created object, passing
   an array of two values: 'param1' and 'param2'
4. Encode the result inside an JSON object
5. Send it back to the browser

You may also use different extensions, like xml and txt. Remember you can still access the $_POST, $_GET, $_SESSION and $_COOKIE arrays from within your model class.

Send questions to ram.coelho AT gmail DOT com. Ricardo Coelho

You can’t perform that action at this time.