It is a strong tendency in our sector to have increasingly more frontend code and present the user with rich client applications. As a result, new and better ways of organising client code have appeared.
We, in Limenius, as Symfony lovers, have been exploring ways to combine it with these techniques. In the first versions of Symfony 2 Assetic was the preferred way to manage assets. However, as the frontend world develops better tools, it makes sense to use them. At the present moment, we consider Webpack a great choice and we prefer it over Grunt or Gulp for new projects. On the other hand, after long time working with Backbone.js and also Angular 1, we are very happy with React.js.
This means that we have the possibility of rendering React components beyond SPAs, in fields like classified ads, that rely on SEO and also want fast content load, while providing an up-to date user experience.
In order to have this, what would we want?
- To have a nice frontend set up with Webpack, with well organised assets, hot-reloading that refreshes the page on changes, that is comfortable and agile in development and produces optimized assets in production.
- To be able to render React components from Twig tags and choose if we want to render them server-side, client-side, or both.
- To do this without the need of running a node.js HTTP server that renders React for us and that would add operational complexity.
Can we have it? Yes we can. While exploring what would be the best way to do this I stumbled upon the React on Rails project, that does a great job. Can we have the same in Symfony? Of course we can! (don’t worry, we won’t write any Ruby ;). For that we have published the following on Github:
- ReactBundle. A bundle to render React components in Twig templates and be able to configure if we want them to render client-side, server-side or both.
- A sandbox that integrates the bundle, provides an example App and has a default Webpack configuration.
We will also use the React on Rails npm package to expose and render our React components with error logs and whatnot.
- 2015 review
- Scaling real-time: Handling 100k connections in a single t2.medium instance with Carotene
- A better PubSub with Redis in Erlang
- My Vim configuration
- Sudoku in AngularJS
- DeSymfony 2013
- My talk at SunshinePHP 2013
- La Brisca
- DeSymfony 2012
- sf2vigo 2011
- Desymfony 2011
- Writing a new Doctrine2 extension
- Playing with Node.js
- Hint to avoid memory exhausted error (symfony + doctrine1.2)
- De vuelta de las Jornadas Symfony