This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Errors in "Creating pages in Symfony 2" chapter

About symfony tutorials, symfony book and API documentation.

Errors in "Creating pages in Symfony 2" chapter

by mangstadt » Sun Mar 13, 2011 6:40 pm

Hi there!

I noticed some errors in the Creating pages in Symfony 2 chapter of the book.

1. ==============
The following text is incorrect:

"If you've downloaded the Symfony Standard Edition, delete the src/Acme/DemoBundle directory, as you'll recreate it in this chapter."

Deleting that directory, then running the "init:bundle" console command to recreate the bundle generates this error:

"PHP Fatal error: Class 'Acme\DemoBundle\AcmeDemoBundle' not found in /home/michael/Symfony/app/AppKernel.php on line 24".

After removing references to this bundle from AppKernel.php and autoload.php, running the command again causes an "InvalidArgumentException" exception to be thrown. I haven't been able to figure out how to remove this bundle.

2. ==============
In the second "HelloController" code sample, the first parameter in the call to the render() method reads:

'HelloBundle:Hello:index.html.twig'

The bundle name is incorrect. It should be:

'AcmeDemoBundle:Hello:index.html.twig'

3. ==============
In the Twig code for "layout.html.twig", the first line reads:

{% app/views/layout.html.twig %}

This should be a comment, not a statement:

{# app/views/layout.html.twig #}

Thanks for the great framework! I'm new to Symfony and am loving it so far! :D
User avatar
mangstadt
Junior Member
 
Posts: 10
Joined: Sun Mar 13, 2011 6:36 pm
Location: Philadelphia, PA

Re: Errors in "Creating pages in Symfony 2" chapter

by xil3 » Mon Mar 14, 2011 4:27 pm

Regarding your first point, I experienced the same issues.

Have you managed to find out anymore information about that? It seems to be a bit of hit and miss with this new version, so far...
xil3
Junior Member
 
Posts: 1
Joined: Mon Mar 14, 2011 4:25 pm

Re: Errors in "Creating pages in Symfony 2" chapter

by halfer » Wed Mar 16, 2011 11:17 pm

Thanks for noting the issues with the docs, I'm sure it's appreciated by the core team. However, they won't get noticed here!

Would you kindly raise a ticket on trac for this? If you don't already have an account, you can get one here:

http://www.symfony-project.com/user/new

Thanks :)
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Errors in "Creating pages in Symfony 2" chapter

by mangstadt » Sat Mar 19, 2011 4:11 pm

I looked into this issue in more detail. The reason why it was throwing the InvalidArgumentException when trying to create "Acme\DemoBundle" was because the bundle was being referenced in the Doctrine configuration in "app/config/config.yml". When I commented this out, it worked fine.

So in addition to deleting the src/Acme/DemoBundle directory, the instructions should also include:
1. Remove this line from app/AppKernel.php: "$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();"
2. Remove this line from app/config/config.yml: "AcmeDemoBundle: ~"

I also ran into issues with the cache. If I load "http://localhost/app_dev.php" in my browser (before creating the Acme\DemoBundle), it will create a "dev" folder under app/cache. Because the web server created this folder, the web server user has ownership of it, so when I ran init:bundle to create the Acme\DemoBundle, it threw an error saying it couldn't write to this folder. You might want to include a note saying either to clear the cache or run the init:bundle command as root.

Thanks, I'll create a ticket for this too.
User avatar
mangstadt
Junior Member
 
Posts: 10
Joined: Sun Mar 13, 2011 6:36 pm
Location: Philadelphia, PA

Re: Errors in "Creating pages in Symfony 2" chapter

by mangstadt » Sat Mar 19, 2011 4:27 pm

User avatar
mangstadt
Junior Member
 
Posts: 10
Joined: Sun Mar 13, 2011 6:36 pm
Location: Philadelphia, PA

Re: Errors in "Creating pages in Symfony 2" chapter

by masterkrang » Mon Mar 28, 2011 3:11 am

I ran into the same issues, I can basically agree with all of the above. Has anybody fixed the issue with the AcmeDemoBundle?

Problem is that once you delete the src/Acme/DemoBundle and try to comment out all of those lines, you end up getting this error:

php app/console init:bundle "Acme\DemoBundle" src
PHP Fatal error: Uncaught exception 'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException' with message 'The path "doctrine.orm.entity_managers.default.mappings" should have at least 1 element(s) defined.' in /var/www/Symfony/vendor/symfony/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php:165
masterkrang
Junior Member
 
Posts: 16
Joined: Thu Mar 24, 2011 6:10 am

Re: Errors in "Creating pages in Symfony 2" chapter

by mangstadt » Sat Apr 02, 2011 6:13 pm

Oh, maybe you have to remove the "mappings:" line too. So these two lines should be removed:

Code: Select all
mappings:
  AcmeDemoBundle: ~
User avatar
mangstadt
Junior Member
 
Posts: 10
Joined: Sun Mar 13, 2011 6:36 pm
Location: Philadelphia, PA

Re: Errors in "Creating pages in Symfony 2" chapter

by halfer » Tue Apr 05, 2011 12:41 am

Note - if a ticket is still open, and appears to have had no action for a while, then raise it on the users mailing list - that's where the core devs lurk :)
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Errors in "Creating pages in Symfony 2" chapter

by mangstadt » Wed Apr 06, 2011 1:19 am

@masterkrang: Actually, I was able to create the bundle by just removing the "AcmeDemoBundle: ~" line. I am using PR7, so maybe this is different for other versions.

I sent a message to the users mailing list. Thanks for the tip! :D~:-D~:grin:
User avatar
mangstadt
Junior Member
 
Posts: 10
Joined: Sun Mar 13, 2011 6:36 pm
Location: Philadelphia, PA

Re: Errors in "Creating pages in Symfony 2" chapter

by mangstadt » Mon Apr 11, 2011 5:34 pm

The ticket has been fixed. Thanks for the help! :D
User avatar
mangstadt
Junior Member
 
Posts: 10
Joined: Sun Mar 13, 2011 6:36 pm
Location: Philadelphia, PA