Best Restful Micro PHP Framework with Code Example and Tutorial

best restfull micro php frameworkCreating a web service without framework is very hard. Web service is an application that can be accessed via the URL or Restful. Most web service use restful  to interact with client, the reason is easy to use and simple. You can open a web service easily. With restfull micro PHP framework, you can build a web service quickly, easy and secure. There are many options restfull PHP framework you can choose, in the list below I put together a few restful micro PHP framework, completed with example code.

For example,  you want to create a web service to serve real- time data transport in a town. This web service can be accessed from anywhere, even can be accessed via mobile devices. You can also open a commercial web service, for example, the data soccer live, premium content networks like newscreed and others.

Restful micro PHP framework is certainly not a big framework, and may not be implemented for a large project. This framework is suitable for learning, however, you can still use this framework to a real project in real life.

1. Recess – Restful PHP Framework

recess

Recess is open source restful php framework that designed for easy building web service. Recess is fast, light-weight, and has a very small footprint—ideal for LAMP development and drag-and-drop deployment to shared hosts. Thanks you Kris Jordan for creating this awesome framework. Download

2. Flight Resfull PHP Framework

flight

Flight is very lightweight restfull PHP framework. You can easily and quickly creating web service with this awesome stuff.

<?php
require 'flight/Flight.php';

Flight::route('/', function(){
    echo 'hello world!';
});

Flight::start();
?>

Another code, you can access it here. I think the code is very easy to learn and read. Everyone can understand it. Download

3. Tonic Restfull PHP Framework

tonic

Tonic is open source restful php framework to build web service.  Download

<?php
 
/**
 * @uri /hello
 * @uri /hello/:name
 */
class Hello extends Tonic\Resource {

    /**
     * @method GET
     * @provides text/html
     */
    function sayHello($name = 'World') {
        return 'Hello '.$name;
    }
}
?>

4. Grape Restfull PHP Framework

grape

Grape allows you to build lightweight APIs with Ruby when you don’t need the heavy lifting power of large frameworks like Rails. It’s a REST-like API micro-framework built to complement existing web application frameworks by providing a simple DSL to easily provide APIs

Download

5. Toro restfull php framework

toro

Toro is a PHP router for developing RESTful web applications and APIs. It is designed for minimalists who want to get work done.

Code example :

<?php
class MainHandler {
    function get() {
        echo "Hello, world";
    }
}
 
Toro::serve(array(
    "/" => "MainHandler",
));
?>

I think, using toro is not hard, codes are easy to learn. Beginners are welcome. Download

6. BulletPHP Restfull Framework

Bullet is a functional PHP micro-framework that helps you easily create REST APIs and web applications that automatically conform to the requirements of the HTTP specification.

Code example

$app = new Bullet\App(array(
    'template.cfg' => array('path' => __DIR__ . '/templates')
));
 
// 'blog' subdirectory
$app->path('blog', function($request) use($app) {
 
    $blog = somehowGetBlogMapper(); // Your ORM or other methods here
 
    // 'posts' subdirectory in 'blog' ('blog/posts')
    $app->path('posts', function() use($app, $blog) {
 
        // Load posts once for handling by GET/POST/DELETE below
        $posts = $blog->allPosts(); // Your ORM or other methods here
 
        // Handle GET on this path
        $app->get(function() use($posts) {
            // Display all $posts
            return $app->template('posts/index', compact('posts'));
        });
 
        // Handle POST on this path
        $app->post(function() use($posts) {
            // Create new post
            $post = new Post($request->post());
            $mapper->save($post);
            return $this->response($post->toJSON(), 201);
        });
 
        // Handle DELETE on this path
        $app->delete(function() use($posts) {
            // Delete entire posts collection
            $posts->deleteAll();
            return 200;
        });
 
    });
});
 
// Run the app and echo the response
echo $app->run("GET", "blog/posts");
?>

Real app example : scrum pocker. I think BulletPHP is hard to learn, maybe suitable for advance programmer.

Download this framework, here

7. Frapi

Is a restful framework that focuses on the system, so as to better serve the request. FRAPI takes care of handling multiple media types, returning the correct response codes, generating API documentation, and much more. Find FRAPI on Github

8. Slim Framework

slim framework

Slim is a PHP micro framework is popular lightweight PHP framework and restfull framework. There are many tutorial how write code to building web service with slim framework. Actually Slim Framwork is not restfull framework in specifically (such as cakephp), but he has Restfull feature, so I incorporate it into this list.

Some tutorial to creating web service with Slim

  1. http://coenraets.org/blog/2011/12/restful-services-with-jquery-php-and-the-slim-framework/
  2. http://www.ibm.com/developerworks/xml/library/x-slim-rest/index.html?ca=drs
  3. http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-12-2/
  4. https://coderwall.com/p/otcphg
  5. http://www.sitepoint.com/writing-a-restful-web-service-with-slim/

And many more.

You can download Slimframework here

Web developer, big fan of CakePHP, loving wordpress soo much. You can found him on Google+ and Facebook. Dont forget to follow him on Twitter.
Posts created 562

9 thoughts on “Best Restful Micro PHP Framework with Code Example and Tutorial

  1. I think that Slim is the best one, beacuse we can build middlewares that are extremely useful to make your app secure and reduce code writing.
    Congrats for the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top