Angular 2 server side rendering coming to Symfony and Twig
Angular is a household name when it comes to JavaScript frameworks. They've been going through a major transition since the announcement of Angular 2. In the latest development Angular 2 will be getting PHP / Twig support for isomorphic rendering.
The news come from a talk on Angular 2 and the future of HTML5 apps from Brad Green. In this discussion he says the team is working on Universal Rendering - pre-rendering Angular 2 application state on the server - for platforms other than their native JavaScript. Among Java and .NET platforms, PHP and the Twig templating engine also gets a mention:
So the Angular and the Drupal development teams have started working together to bring Universal Rendering to PHP and Twig. The details remain murky on how exactly this will be implemented (using a Node.js server or a PHP library), but a PHP library (not an extension written in C) would be the easiest option for developers.
This feature is being developed by two product teams (Angular and Drupal) and there is an opportunity that the implementation will be coupled with Drupal:
In the past Drupal has been criticized for being a freeloader in the PHP community as of late, but this is a great opportunity for them to create something that is usable for hundreds of thousands of non-Drupal developers. We urge the Angular and Drupal teams to work to make this a generic PHP/Twig component and not something that is tightly coupled (ha-ha) with Drupal.
- Drupal team working on Angular 2 Universal support for Twig / PHP
While it will probably be relatively easy to plunder the code from Drupal. But ideally we would get a general purpose Universal Rendering component that could be installed with Composer and easily used across all kinds of different PHP applications. Not just Symfony and Drupal.
Learn more about Isomorphic Rendering:
- Introduction to React.js Components and Server Side Rendering in PHP
- Testing React.js isomorphic rendering with php-v8js and the Symfony Microkernel
- Rendering Riot.js tags in Twig using Node.js
- Drupal 8 REST API and Isomorphic JavaScript