SymfonyWorld Online 2021 Winter Edition December 9 – 10, 2021 100% Online 25 talks and 10 workshops

Introducing the Symfony Demo application

Today we're glad to officially introduce the Symfony Demo application. This project is a fully-functional Symfony application developed as a learning resource. The application deprecates the old AcmeDemoBundle and it can be considered the reference implementation of the Symfony Best Practices.

Technically, the application consists of a blog engine with both a public and a private section:

Symfony Demo Homepage

The private section is a simple CRUD backend developed from scratch:

Symfony Demo Backend

Every application page includes a Show Source button which displays the Symfony controller and the Twig template used to render the current page:

Symfony Demo Source Code

In addition, the source code of the application contains tons of comments to help you better understand why and how things work.

How to install the Symfony Demo application

Open a command console and execute the following command anywhere in your system:

$ symfony demo

This command leverages the Symfony Installer to download and install the demo application. If the demo command doesn't work, update your old installer version executing symfony self-update. Once the demo application is downloaded, use the built-in web server to run it:

$ cd symfony_demo/
$ php app/console server:run

The Symfony Demo application is designed to run out-of-the-box, so you won't need to configure anything or run any other command. Alternatively, you can get the demo application through the symfony/symfony-demo repository.

What is this application useful for?

1) Learning Symfony

This is the most obvious reason to use this demo application and its main purpose when we developed it.

2) Teaching Symfony

This application can also be a useful teaching resource to train your company interns and to deliver workshops during events organized by the Symfony community.

3) Testing new Symfony features

Do you want to test the great features introduced by a new Symfony version without messing your applications up? Install the demo application, update the Symfony dependency and you're done!

For example, you can test Symfony 2.7 beta features as follows:

$ symfony demo
$ cd symfony_demo/
$ composer require symfony/symfony:[email protected]

4) Relative benchmarks

The demo application is developed as a learning resource, so you cannot use it in a performance benchmark. However, it can be used to do relative performance benchmarks.

Install a fresh new demo application and profile it with Blackfire. Introduce some changes in the application and profile it again. You can now visually compare both executions and check out how much the application performance improved or degraded.

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


It's cool!
I like AcmeDemoBundle, but Symfony Demo application seems more interesting at first sight!
Why not publish the package on Packagist as well, for people who think Composer does a fine job creating projects already? :)
There is no pagination in admin? So still no best practice for pagination?
@Maninder what best practice are you talking about ?
this is absolutely awesome. I think many users were waiting for it for quite a long time.

congratulations to everyone involved
@Christophe instead of a "pagination best practice", I guess that @Maninder refers to "the official example about how to implement pagination in Symfony applications". We'll add that pagination example soon.
Thank you for the demo. Are voters implemented?
`web/bundles` folder included in the repo? Shouldn't it be installed via assets:install command?
Is it best practice to place all the views in app/Resources/views? Why not in AppBundle/Resources/views ?
@Sergiu there are no voters yet, but we'll implement them in the future.

@Jacek we needed to do some things to make it work out-of-the-box without executing any command. We'll improte it in the future. In any case, the error is not critical for the end users of this application because they never see the repository.

@Niels as a matter of fact, the best practice states that templates should be stored in app/Resources/views/. You can read the explanation in
@Stof Will there be a bundle for this demo ??
@Sofien there are no plans to create a bundle for this demo. This project is intended to use it as a stand-alone application to showcase Symfony features.
Great!!! I remeber the book and the demo app of symfony 1.3. Now we have new one foe symfony2!!!!!!!!!
This is awesome. Very much needed and useful.
This is perfect! Please upload more examples like this.
Well, this is far from a reference implementation of best practices on Symfony.

First of all, you see a basic example of bad code, where entities are being populated and saved directly in a controller ( A good solution for that would be split these two different actions into Hydrators – to populate the entities – and Managers – to save them abstracting the persistence layer away (yeah, here you're coupled to Doctrine's entity manager).

Another problem is forms being created on the fly, directly on the controllers ( Symfony allows you to do that, and that's very, very good. But that doesn't mean you should be doing it. Keep your form implementations separate – really, really far – from your controllers. Each form can have it's own implementation and even each field for that matter. On a basic example like this, that might seem a bit of overhead, but trust me: most applications tend to grow fast and this is a very bad example to follow.

One more example of weird practice would be the definition of an AppBundle that holds the entire application. Come on? We're passed that since a long time now. Bundles are supposes to integrate thirdy-party libraries into Symfony and add functionality on top of that. Let's not put our code into bundles, that doesn't make sense. Unless, of course, you want to be coupled Symfony's structure from the beginning.

Well, at least the layout looks nice.

The bottom line for me is: to find out about best practices with Symfony, try to follow successful projects on top of that framework, such as Sylius and so on. Even Sylius has its problems, but at least the community is aware of them and is trying to find solutions for those.
Great, extremely useful! Thank you!
yeah, big step !! awesome guys
>> Javier Eguiluz
>> ...
>> We'll add that pagination example soon.

@Javier Will you want to use KnpPaginatorBundle for it or implement your custom simple pagination?
@Victor, I guess it would make sense to use the most popular pagination bundle (KnpPaginatorBundle) instead of doing it manually.
I really like the way we install the demo application, I would just change the command name to be more explicit, something like, demo:deploy or demo:install. And what about the tests?! Not really Symfony related, but an official application that advocates good practices, should have tests in place.
@Javier Thanks, it will be great!
@Christophe I mean there is no single suggested way to apply pagination to help beginners. When I saw posts admin section in demo I thought there should be pagination applied there. But there was no pagination there.
@Tito we prefer the "demo" command name to keep things simple. Regarding the tests, we already have unit and functional tests in but you are right and we need to add more of them. We'll do it soon.
This Symfony demo application is awesome. I just love how new features have been announced in the past few days. Thanks to everyone involved.
You have placed the Form Type classes in "Form" directory instead of "Form/Type". Is that correct? Where will you put the Event Listeners and Subscribers for the forms?
@Gonçalo you are right about form type location. In fact, we discussed about it in the past ( and we'll probably fix it in the future.
Decided to look what's symfony. After YII, CakePHP and Codeigniter I was a little shocked by how to do basic things like pagination. It seems to me it is still too early to know :)
@Donika you can use KnpPaginatorBundle, or a plugin like Datatables
Thank you guys. It's very usefull example
Great job, thank you for demo application.
Awesome-ness, many thanks. ;)
Great !!! thanks for the demo app.
This is New Version 2.7 of symfony ?
The demo is nice, a good way for newcomers to get to know how symphony works. I did notice that if you add a demo post of same titles then two posts with same route exist.

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.