Tools to build a REST API in PHP

If you want to build a REST API in PHP there are many tools to choose from. This post gives you an overview about available tools and explains the basic features, which should help you to choose the right tool for the job. Also I give a personal recommendation for which use-case I would choose the tool.

Note: I`am also the developer of Fusio which is listed here but I`am trying to be as objective as possible. If I have missed any tools or make wrong claims please let me know on Twitter.

We take a look at the following tools:


Micro-Frameworks (i.e. Slim, Lumen) are great to build fast simple API endpoints which i.e. query data from a database or execute some simple business logic. You can build anything you like but there are no build-in features so you need to cover topics like OAuth2 Authorization, OpenAPI export, Schema validation, Rate limiting etc. by yourself. A micro-framework is basically a routing mechanism which invokes a function if a request arrives.

I would recommend a Micro-Framework if you want to build an internal API at your company i.e. for a micro-service. I would not use it for an API which is exposed to a customer since then you need to cover most features by yourself.


Classical Frameworks (i.e. Symfony, Laravel) come from the Web 2.0 area they have a template engine, form components etc. and are mostly used to generate HTML on the backend. They can all easily return JSON data in the controller but at the core they offer the same functionality as a micro-framework. Through plugins it is possible to extend such frameworks. Most notable for Symfony there is the FOSRestBundle which uses the JMS Serializer, it allows you to extend your entity with annotations to describe how the entity should be serialized. For Laravel there is also Dingo which helps to build APIs.

I would use a framework if you have already an app build with it. Then you could simply use your existing models to create the API. But I would recommend this only for simple APIs since you need to cover more advanced API topics like Oauth2 Authorization, OpenAPI export, Schema validation, Rate limiting etc. by yourself.


API-Platform is based on Symfony and uses also an entity based approach to build APIs. This means at the core of your API you need to create an entity containing specific annotations and the API-Platform creates based on this the complete API. There is also a Backend/Client app to CRUD those entities. Also it is possible to automatically generate an OpenAPI definition for your API.

I think if you need to build a simple API based on doctrine entities it is a great tool. But the entity approach also limits you. I.e. if you want to define custom routes or if you need to build API responses based complex SQL queries. Since Doctrine is used as an ORM it has a performance penalty, this can be solved by using a reverse proxy but then you have to deal with cache invalidation. Also endpoints are always based on an entity, there is no possibility to build endpoints which proxy to other micro-services (API Gateway). Topics like Analytics, Rate limiting, Pub/Sub and Monetization are not covered and must be implemented by yourself.


Fusio is an open source API management system which is designed to simply create REST APIs. It has a micro-framework like approach, this means you can define routes which invoke a specific action. This action contains then the business logic of your endpoint and returns the response. Before the requests arrives Fusio makes several checks whether the user is authorized, rate limit is not exceeded and the request data is valid. The user can attach a JSON schema definition for the request/responses so that Fusio can automatically generate an OpenAPI definition.

There is also a backend app which allows you to control and monitor your API. You can use the developer app to simply build a developer portal for your API where new users can register. Besides this Fusio covers also more advanced API topics like Pub/sub and Monetization.

If you want to build a complex API I would recommend to use Fusio since most API features are already covered. If you like to build an API based on an entity I would recommend the API-Platform.

In this post we have covered the most known tools to build APIs in PHP. I hope I could provide a neutral overview of each tool and I could help you to choose the right tool for your API project.

I am a developer in the API space, currently working on Fusio an open source API management platform

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store