Comparing API Platform and Symfony Encore with ReactJS

This article have been written in Oct 2019 and the goal is to compare at this date the main differences between the 2 projects. No proper comparison have be found yet by myself, so I am writing one !

Symfony

It is a PHP framework that allow to produce webapp, web API, etc. Backed by Sensio Labs. More details here.

Symfony Encore

It is a Symfony package that allow to use frontend javascript inside Symfony. It allow using ReactJS within Symfony. Here is some example and the official documentation:

It is possible to have a Single Page Application or to create multiple React app inside the same Symfony package. You must run the symfony server and the encore app when you are developing on the application. There is no ‘auto-refresh’ feature like you have on a CRA React app.

1*JNXkUF-GiQCEPxGW9e5bUg.png

API Platform

API Platform is an developement environnement, based on Symfony, that allow to create and deploy an application with an API backend (REST or GraphQL), and a frontend (React by default). It is API-first in mind.

The documentation is here https://api-platform.com.

The development environment is based on Docker containers, and it has been developed to make it easy to deploy on cloud ready systems (like k8n or other).

1*rxjwaeRe5eDIFCrMIETk_Q.png

There is no way in this project to use the ‘default’ template layout of Symfony, you must have a SPA application. There is only one React app needed !

Which one to choose ?

This is an hard point. Each solution comes with specific advantages.

The API part of API Platform is in fact a composer package that you can easily install on a existing Symfony platform ( composer require api ). You will then be able to use the very powerful annotation @ApiRessource to present any entity as full CRUD REST API (see here).

I think it is easier to integrate slowly a ReactJS frontend with Symfony Encore, as you can keep your codebase and existing templates. But API Platform is more powerful when starting brand new project that will need a webapp and a mobile app.

What is your choice ? Let me know !

No Comments Yet