Symfony2: Getting Started

A quick post on a couple of issues I had getting started with learning Symfony2.

I have started by downloading the Preview Release 8 Symfony Standard edition from http://symfony.com/download. My intention is to start working through the book. My first hurdle was working out what to set the document root in the vhost file to in order to just get it started as this does not seem to to be clearly documented. After looking in the downloaded files it looks as though it needs to point to /path/to/app/AppName/Symfony/web which means I now get the welcome page at /app_dev.php

I had some issues getting started with the very basic application - on the Page Creation page it says to delete the demo bundle if you downloaded the standard application. I did this, it then broke so that I cannot recreate it using the CLI tool. As advised I tried to run:

php app/console init:bundle "Acme\DemoBundle" src

but was getting the following error:

Class 'Acme\DemoBundle\AcmeDemoBundle' not found 
in /path/to/app/AppName/SFTest/Symfony/app/AppKernel.php on line 20

Commenting this out:

new Acme\DemoBundle\AcmeDemoBundle() 

in the file in the error message got around this error. I now instead was getting this PHP Fatal error

 Uncaught exception 'InvalidArgumentException' with message 
'Bundle "AcmeDemoBundle" does not exist or it is not enabled.' 
in /path/to/app/AppName/Symfony/vendor/symfony/src/Symfony/Bundle/
DoctrineAbstractBundle/DependencyInjection/AbstractDoctrineExtension.php:77

It was much less obvious how to fix this one. I had to comment out all of these lines

orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager: default
        entity_managers:
            default:
                mappings:
                    AcmeDemoBundle: ~

in /path/to/app/AppName/Symfony/app/config/config.yml

The command would then run and the demo bundle was created and I could continue working through the book. I think this is an issue with the documentation but since Symfony2 is only at PR8 then the documentation is a work in progress and will no doubt be improved by the time there is a stable release.