This a Symfony implementation of TodoMVC.
TodoMVC is a project which offers the same Todo application implemented using MV* concepts in most of the popular JavaScript MV* frameworks of today.
It uses Backbone.js and Chaplin.js client-side and FOSRestBundle for the REST JSON API server-side. The client-side code is wrote in CoffeeScript.
Try it online: http://symfony-todomvc.dunglas.fr/
Yes, this is TodoMVC.
First, install Symfony using Composer. Go to your application directory and use composer to install the bundle and its dependencies:
composer require dunglas/todomvc-bundle
Next, enable these bundles in AppKernel.php
:
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new JMS\SerializerBundle\JMSSerializerBundle(),
new FOS\RestBundle\FOSRestBundle(),
new Dunglas\TodoMVCBundle\DunglasTodoMVCBundle(),
// ...
);
}
Add these lines at the end of app/config/config.yml
:
fos_rest:
routing_loader:
default_format: json
body_listener:
decoders:
json: fos_rest.decoder.jsontoform
Add DunglasTodoMVCBundle to Assetic's bundles option in config.yml
:
assetic:
#...
bundles: [ DunglasTodoMVCBundle ]
And the routes to app/config/routing.yml
:
dunglas_todomvc:
resource: "@DunglasTodoMVCBundle/Resources/config/routing.yml"
prefix: /
Install assets:
php app/console assets:install web
Dump assets if you want to use the app in prod mode:
php app/console assetic:dump --env=prod --no-debug
Create database schema:
php app/console doctrine:schema:create
Done! Open http://localhost/app_dev.php in your browser and try this Symfony implementation of TodoMVC.
If you want to rebuild the client-side CoffeScript code go to the Ressources/
directory and run:
coffee --bare --output public/js/ coffee/
Add the --watch
option to recompile at each change.
Of course you need the CoffeeScript compiler.
TodoMVC is unsecure by design. Everyone can do everything. If you create a real world Symfony + Backbone.js app be sure to add an authentification system and a CSRF protection layer.
Utiliser Chaplin.js et Backbone.js avec Symfony 2 : installation et configuration
- Configure FOSRestBundle and AsseticBundle directly in the extension
This bundle has been created by Kévin Dunglas. The CoffeeScript code is largely inspired of the Brunch + Chaplin TodoMVC implementation of Paul Millr.