Top 10 Best PHP RESTful Micro Frameworks (Pro/Con)

Written by on June 24, 2019

Top 10 Best PHP RESTful Micro Frameworks (Pro/Con)

Wow, I wrote the original version of this article almost four years ago, in software development time it was a long, long time ago. I will do a little spring cleaning, and maybe some polishing around the edges.

To make story short, I’m first and foremost Java developer who ended up working with PHP and I liked it. During this initial PHP introduction I had to create a small RESTful project; nothing fancy-schmancy, but speed was the main requirement.

Fast forward, I have had spent several weeks going through at that time most important PHP RESTful Micro-Frameworks. My original article was a fruit of that labor, so to speak.

Over time, PHP RESTful micro frameworks this become my obsession, so I kept looking at what’s new and available.

I will try to be objective, emphasis on try. If you know of a framework which is missing on below list please leave a comment below.

Update: 21th June, 2019 - Trimmed this list from 12 to 10 frameworks. Included Laravel.

Table of Contents

Recomendations

For those of you who do not have time to read. here’s my favorite four:

  1. Silex
  2. Slim
  3. Laravel
  4. Phalcon

For more information, scroll down and read my reviews.

Intro

Please take a look at the list of my chosen twelve, in alphabetical order:

1. BulletPHP

Introduction date: 2012

The Bullet is a rather newer addition to PHP micro-framework community with a unique approach to URL routing. It helps you quickly create REST APIs and web applications that automatically conform to the requirements of the HTTP specification. Unlike most of it, brethren Bullet is a resource and URI-oriented and comes pre-loaded with powerful HTTP features like content-negotiation and caching.

Fundamentally that means instead of defining a full path pattern or a typical URL route with a callback and parameters mapped to a REST method (GET, POST, etc.). The Bullet can parse only ONE URL segment at a time, and only has two methods for working with paths: path and param.

Links

Official Site
GitHib
Documentation
Installation, Working Example

Pro

  • Its unique design prevents a lot of code duplication. Nested closures are crucial to how Bullet works; they work similarly to jQuery callback functions. Look at an example below to see a difference.
  • Since URL routes are handled on segment per segment basis; code provides high re-usability, which is unique in current micro frameworks world.
  • URL routes handle only a single path segment
  • URL routes can be crafted without restrictions, giving you an ability to nest them as deep as you want.
  • Caching of table metadata

Con

  • Documentation is lacking enough information to get you started (I advise you to take a look at the above link Tutorial, Installation, Working Example). It lacks a better organization. Currently, it is not beginner friendly; it took me some time to make it work. It’s 2019 and it still sucks.
  • New routing model, while excellent, still doesn’t feel that much flexible. This approach still suffers from code bloatedness and code mixing.
  • Was dead for a bit; it may happen again.

Example

$app->path('posts', function($request) use($app) {
    // Get posts collection
    $app->get(function($request, $postId) use($app) {
        return "GET  /posts";
    });
 
    $app->param('int', function($request, $postId) use($app) {
        // Get single post resource
        $app->get(function($request) use($app, $postId) {
            return "GET  /posts/" . $postId;
        });
 
        // Update single post resource
        $app->post(function($request) use($app, $postId) {
            return "POST  /posts/" . $postId;
        });
    });
});

Author Notes

This framework is a good starting choice, mainly for smaller projects. New routing model makes it very versatile.

On the other hand, because of its age and simplicity, you will need to mix it with other frameworks. Mostly because, unlike some older frameworks (like Fat-free framework), Bullet doesn’t have additional functionalities (ORM for example).

2. Fat-Free Framework

Links

Official Site
GitHub
Documentation
Installation, Working Example

Pro

  • Built-in web server
  • Excellent template engine
  • Lightweight and multifunctional, built like Swiss army knife.
  • Everything is modular.
  • Fast so it should be considered for larger projects.
  • Excellent API and how-to documentation, not the best one but way better than usually expected. Everything is tutorial based, making it easy to follow and implement.

Con

  • Suffers from code repetition, just like some other similar frameworks.
  • It’s overkill if you are not going to use most of it functionalities
  • ORM module is easy to implement/configure, but there’s a lot of room for improvements. Of course, you can always use another one.

Example

class WebPage {
    function display() {
        echo 'I cannot object to an object';
    }
}

$f3->route('GET /about','WebPage->display');

Author Notes

The Fat-free framework is an excellent piece of software. While there’s nothing innovative about it, you will be surprised how much functionality is provided for you. Not to mention it runs smooth and fast. It is half way between micro frameworks and larger frameworks like Zend or Symphony, more so I find it to be an excellent replacement for mentioned more major frameworks, not to mention, it’s heavily modular.

It gets a job done.

3 Laravel

Introduction date: 2011

Laravel is an MVC-based PHP web application framework with an expressive, elegant syntax. It’s one of the oldest frameworks on this list and probably the best all-around framework here. While it’s not the fastest one, it provides the most extensive and thorough documentation and video tutorial library among all frameworks on this list.

Links

Official Site
GitHub
GitHub Documentation

Pro

  • Large community and easy to learn
  • Probably the best documentation all-around
  • Easy, fast routing engine.
  • Dependency injection implementation
  • Multiple back-ends for session and cache storage
  • Eloquent ORM
  • Database agnostic schema migrations
  • Robust background job processing
  • Real-time event broadcasting

Con

  • Problematic upgrades between major versions
  • Dependency injection can became a pain in the neck as complexity increases
  • Over time it became far from a micro

Author Notes

My first, my only, my everything. A framework of a choice.

4. Limonade

GitHub
GitHub Documentation

Pro

  • This framework used to be a great and in some way it still is. Unfortunately, younger competition overshadowed it some time ago
  • Still slimmer then Slim framework, you can do so much with so little code

Con

  • Bad documentation. I so worse but this one is barely manageable.
  • What you see is what you have, you should forget modulability
  • It gets less and less useful as time goes by

Author Notes

A few years ago I would advise using this framework, unfortunately not anymore. While it is a micro-framework, it is missing some features.
It is simply past its glory.

5. Lumen

The Lumen is a stunningly rapid micro RESTfull framework mad by Laravel. Compared to other frameworks on this list, Lumen is a brand new framework made by Taylor Otwell, designed for ultra-fast micro-services and API’s.

Official WebSite
GitHub
GitHub Documentation

Pro

  • First and foremost, excellent documentation
  • Man it’s fast, but ….
  • Excellent 3rd party support thanks to the bigger brother (Laravel)
  • Easily upgradable to the full Laravel project
  • Easily understandable syntax, to this date this was a fastest “from scratch” setup

Con

  • …. still not faster then Slim, Silex or Phalcon, no matter what is stated in the official documentation
  • Its size doesn’t make it a micro-framework
  • If you don’t like Laravel you’re not going to like this framework

Author Notes

I kind of like this framework. It’s fast though not fastest of them all; it’s easy to implement. While in my experience not as fast as Slim or even Silex it has a MUCH better 3rd party support.

Unfortunately, Laravel fame and some false marketing are hurting Lumen.

6. Phalcon

Link
Documentation

Pro

  • Fastest RETful micro framework available
  • Speed alone places it in whole separate category
  • Extremely optimized and modular, use only what you need or want
  • Excellent documentation, unfortunately not that much 3rd party community support, at lease compared to Silex and Slim. But don’t let this discourage you, you will still find more than enough information.
  • C-language based ORM, especially important if you are creating DB oriented application

Con

  • Nothing special. It doesn’t have such a great vibe like Silex or Slim.

Author Notes

If there were not for Slim, Phalcon would be my number 1 framework. It is the framework of choice for my next project. I’m giving it thumbs up plus my recommendations.

7. Silex

Links

Official Site
Documentation
Installation, Working Example

Pro

  • One of the fastest micro RESTful PHP frameworks, arguably TOP 5
  • Currently best-known framework of this type. At the same time this is the primary reason why I’m not using it
  • Built on Symphony components and modular, use only what you need
  • Great documentation plus 3rd party community support
  • Excellent for large projects

Con

  • Nothing special

Author Notes

Silex is another great if not the best micro RESTful PHP framework. Its connection to Symphony guarantees stable implementation with a lot of available resources. I would argue that only the Slim framework can count as a real competition.

8. Slim

Link
Documentation

Pro

  • Slim is one of the fastest micro RESTful frameworks available
  • Good documentation (it could be better), and then again, a slim framework requires slim documentation
  • Provides you with every feature this kind of framework should have, and nothing more, which is great
  • Unlike a lot of other frameworks Slim has a very large following, basically, a lot of resources are available online, from the original website plus a lot of 3rd party content, including youtube tutorials
  • It has a solution for large routing files in lazy loading. It requires 3rd party implementation so think about it.

Con

  • Nothing special.

Author Notes

Slim is my first and primary choice. I would recommend spending some time with it, you would not regret it.

9. Tonic

Link
Documentation

Pro

  • It works. I don’t have nothing else positive to say about Tonic.

Con

  • It takes a lot of time to get used to, time we can spend on any other frameworks
  • Worst documentation I ever so
  • This is a good option if you have a good knowledge how other similar frameworks work (usually not the case).
  • Github page has more useful information the framework web page

Author Notes

This framework is not a bad choice. Unfortunately, other frameworks have better documentation and additional features this kind of framework should have.

10. The One Framework

Just like the Lumen, the One Framework is a rather new addition to a micro-framework world. Though, unlike Lumen, The One framework is a real MICRO-framework.

Official Site
Link
Documentation

Pro

  • Fast though I haven’t had time to benchmark it properly, especially compared to other frameworks
  • Extremly small
  • No dependencies, add extra libraries only when you need it.
  • Based on Symfony and ExpressJS

Con

  • Rudimental documentation
  • Not for novice developers
  • Not suitable for full stack projects and from my experience it will not play well with some 3rd party plugins/frameworks, mainly ORM-s.

Author Notes

While this framework is not suited for larger projects, I successfully implement it into one of my smaller projects, and it’s working surprisingly well. Of course, it took me some time to make it work, still, I would like to recommend this framework on behalf of its size and speed. Again, not to be used for larger projects.

Categories

56 thoughts on “Top 10 Best PHP RESTful Micro Frameworks (Pro/Con)”

  1. Nice review.
    BTW, your blog has some strange problem with my browser (Chrome 33, Win) that makes an uncomfortable reading: unless I resize the window width to less than 1024 px, a few letters of the paragraphs text overflows the window on the righ (this should not happen) and still Chrome does not show the horizontal scroll bar.

    • Thanks for your comment you were very proactive and helpful. I will fix this problem as soon as possible.

      Edit: Hm interesting, I’ve recreated this problem, also found another one. Apparently I have a problem with my CSS media queries on certain resolutions.

  2. There seems to be some typo (missing ; ) in
    Also, the divs

    show (when inspected on Chrome) at ridicolous large heigth (all the window, it seems).
    Anyway, I’d say that Chrome should be to blame, partially at least. It seems to get confused with the width, it draw outside the window but still believes that everything fits (no horizontal scrollbar, the right arrow key does not work)

  3. Ah, the commenting system ate my html…
    Let’s try again escaping…

    typo in: < div class=”blog-article-content rich-content” >

    very tall divs: < div style=”width:100%height: 0.35em;” >

  4. Thanks for the review but i think you are discussing about micro frameworks but all of them are not micro at least the Phalcon doesn’t belong to micro level and if you didn’t try Laravel (http://laravel.com) yet then you should check it, one of the bests for now, trnding 🙂

  5. Hello,

    Im very thankful for your post here, it really helped me a lot in choosing my next micro. A quick question though, can u explain a little on the security aspects of phalcon, slim and wave ? and how do they cater them. Also, if you have any other better micro in terms of security, do let me know, thanks in advance 🙂

  6. Thank you very much for this article. Can you please make something similar with migrations and oauh2 mini frameworks? Thank in advance

  7. I know it is not easy to assign scores, but I really liked what you did in one of your comparisons with scores.

    It would be nice if these comparisons could have them too.

  8. Should I use a micro framework or full stack like laravel with my project? My project is a government website, the dynamic part and those with admin side are the news, events and gallery.

    • If you’re working on a government job, I would advise using a full stack framework. There’s a good chance they’ll require more and more features so smart move would be to go with the best framework you can master. Initially, it will take you more time to set everything up but you’ll make it up on a long run.

  9. I am new to php and have to choose a rest api framework for a mobile apps where there is max 30-40 rest apis. which rest api framework will be best for me ? Any suggestions

    • First we make a restful api with the necessary routes, offering json resources, listing something (GET), registration something (POST).

      Then do the consumers of these resources json. may be on Android, iOS, WinMobile, and even (HTML5 JS CSS3)

    • And if you are working with HTML views but on a project (consumer) PHP, to consume the routes of API in json, we need the cURL library.

  10. First of all, thanks to the author for this very nice article. I have 14 year php experience, but until now, I had to use more robust frameworks, build my own, or use one that others build privately. Now I’m looking for framework to create backend for a frontend which will based on angular or polymer.

    After inspecting all of these frameworks, I’m hesitating between phalcon and lumen.

    Phalcon looks extremely flexible! MVC functionality is optional for example. It’s data handling seems really well thought up, mature and feature rich. This is the real strength of it. You can even use only for that. There are also quite lot amount of 3rd party resources available (the blog author didn’t mention this important factor besides 3rd party support). While it’s not a requirement for me, but the bootstrap support is big plus for me (It’s well known for me). The php-extension nature makes it more unique, gives speed, but since I can’t debug it via xdebug, can cause problems for me. In many cases, debugging helps understand the code even faster than any amount or quality or documentation. Has great documentation. I don’t care about lower 3rd party support now.

    While I like Lumen’s ability to convert into a robust, very feature rich framework. It’s structure and usage shows similarity to some other framework like Slim, I see as de facto standard at these type of frameworks. It looks very mature and has great documentation.

    • And tham my friend is called a weasel statement, google it.

      1. Who has confirmed that?
      2. On top of what data?
      3. Most performant PHP micro-Framework? What about Java and .NET?

      I hope you get a gist.

      • “The benchmarks themselves are actually really simple. I use a Homestead VM since that is something anyone can recreate. In my tests, I allocated 2GB of RAM to the machine. Of course, benchmark numbers are going to vary depending on the hardware of your host machine. I personally am running benchmarks on a 2012 Macbook Pro Retina 15″ with 16GB of RAM. So, don’t be surprised if your numbers are different than my numbers.” ~ Taylor Otwell (Creator of Lumen)

  11. Wrong, Lumen is the fastest of all micro framework and besides 3 Slim has been updated in the butts to improve the speed knowing that Lumen has basic library of more than Slim. Lumen is top notch for a small application instance with most unlike Slim or otherwise. You could even add a category limit “very little micro framework ” for the framework as bullet or slim.
    Thank you for this article

    • It depends how you define fast but Lumen certainly isn’t the fastest, Phalcon is by far the fastest in terms of response times and request per second because its Libary is written in C, no pure PHP implementation will ever be able to compete with that

      • Sure, but there we are not comparing the same things. Besides Zend Framework should have taken a direction as to Phalcon , allow users the option of using a php framework in compiled dll taking example of Phalcon but Phalcon not a very practical framework on long- term projects , professionally and in a team.

        • How is not practical for long term projects and teams? It is really easy to extend and if you have Phalcon Devtools it is to generate your classes.

          • He thinks it is not practical because he likes Lumen, he somehow has turned a blind eye to anything that is actually faster than Lumen, Phalcon Full Framework is faster than Lumen. Codeigniter 3 is faster than Lumen, Phpixie is faster than Lumen. There should be a category for bloated frameworks so Laravel can shine in that category.

  12. We don’t trust components such as Composer, on our server, so many of these frameworks will not do.

    • Most of PHP development world is moving to packages and Composer install… so not sure why you wouldn’t trust a Composer package vs an all inclusive framework. You will have to vet them equally for malware.

  13. Our team is planning to develop a large REST API that will deal with large amount of data and speed is a primary issue in here.
    Which framework do you suggest? Can we go with micro-frameworks?

    • Api platform looks good.. but! Spend a lot of time just to make it works! Doc outdated, no body cares. So if your time is really short not best choice at all.

      • I found the opposite. It was up and running in a couple of minutes and there is an active slack channel and bitter room where people will help out.
        It’s also based on symfony which should make it easier for people who already use it.

        • Depends from the task I think. I need Crypto field and Dynamic fields ‘json’ but Symfony bundles support only Psql for this! And this framework actually expects only Mysql. It even hardcoded in the tests. Each shanges I have to remove dir in ‘var’…

          • Ah ok, I think I saw you in the gitter group. Maybe try asking in the symfony-devs slack group as the creator is around there in the api-platform channel.

Leave a Reply