The server-sent event API is a great new alternative to using AJAX for long polling the server for updates. This new API has a very simple JavaScript interface as well as an easy to understand server implementation and it is also more efficient while having a built-in reconnection feature. If your application requires a simple data feed or there is a need for a rapid prototype then the server-sent API might be the ideal choice.
To use this recipe, you will need to have a project skeleton with a configured Phalcon bootstrapper, Phalcon\Mvc\Router
, and three Phalcon\Mvc\Controller
. In our example, we will use a project scaffold generated by Phalcon Developer Tools.
To test the recipe results, you need to have a web server installed and configured for handling requests to your application. Your application must be able to take requests, and additionally, there must be such necessary components as controllers, views, and a bootstrap
file.
A database...