Symfony2 – Internal server error 500

Featured Image

Did you ever had problems with Internal server error 500 with symfony2? I did few days ago. When I open my web application in development mode (http://mysymfony2url/app_dev.php/something) It works OK, but when I tried to open it in ‘production’ mode I always got ‘Internal server error 500’ response, so I decided to look at error.log inside my localhost to see what is happening.
Here is what I saw there:

[Wed Jun 15 15:22:44 2011] [error] [client 127.0.0.1] client denied by server configuration: C:/WampDeveloper/Websites/cea.local/webroot/app/
[Wed Jun 15 15:22:44 2011] [error] [client 127.0.0.1] client denied by server configuration: C:/WampDeveloper/Websites/cea.local/webroot/bin/
[Wed Jun 15 15:22:44 2011] [error] [client 127.0.0.1] client denied by server configuration: C:/WampDeveloper/Websites/cea.local/webroot/src/
[Thu Jun 16 08:11:56 2011] [error] [client 127.0.0.1] client denied by server configuration: C:/WampDeveloper/Websites/cea.local/webroot/app/
[Thu Jun 16 08:11:56 2011] [error] [client 127.0.0.1] client denied by server configuration: C:/WampDeveloper/Websites/cea.local/webroot/bin/
[Thu Jun 16 08:11:56 2011] [error] [client 127.0.0.1] client denied by server configuration: C:/WampDeveloper/Websites/cea.local/webroot/src/

There was not enough informations for me to figure out what is wrong with my application.
In development mode it is working just fine, but when I start it in regular (production) mode it returns an error. I tried to delete cache, refresh page, looked in my config files, but I found nothing.

Then I remembered that recently I upgraded to Symfony2 beta4 version and whole my files except configuration files was overwritten with new ones.

Solution: DO NOT forget to register your bundle namespace inside ‘autoload.php’ like I did, otherwise, you can spend few hours to find what is going on without practical solution.

When I added my namespace inside ‘autoload.php’ then everything was OK.

<!--?php use Symfony\Component\ClassLoader\UniversalClassLoader; $loader = new UniversalClassLoader(); $loader--->registerNamespaces(array(
'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio'           => __DIR__.'/../vendor/bundles',
'JMS'              => __DIR__.'/../vendor/bundles',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine'         => __DIR__.'/../vendor/doctrine/lib',
'Monolog'          => __DIR__.'/../vendor/monolog/src',
'Assetic'          => __DIR__.'/../vendor/assetic/src',
'Metadata'         => __DIR__.'/../vendor/metadata/src',
'Surgeworks'         => __DIR__.'/../src',
));
//...

I hope that this post will be helpful to someone with the same problems. 🙂


1 comment

  1. Hi,
    nice post!

    I’m having the same problem and tried to solve it your way, but sorry no success!

    Is ‘Surgeworks’ your Bundle?
    Is __DIR__.’/../src’ …. your bundle path?

    do you think there’s anything else creating problem?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.