Ask your Symfony questions! Pay money and get answers fast! (more info)

Why would back.php have different database access than index.php Symfony


We are trying to move all of our sites to the RackSpace cloud. All of our sites will share one code base, so we took most of the Symfony project and put it in this folder:


Only the "web" directory lives elsewhere. Each web site has a path like:


and in this folder would be other folders like:




We have 2 front controllers:



They live here:


Here is the odd thing:

I can log into index.php just fine. But when I try to log into back.php, I'm told "No such username can be found." I'm using the same username.

Why would the 2 front controllers give different login responses?


I should mention that [[LINK href=""]]WP Questions[[/LINK]] is still on the old server, and there I can log into the backend with no problem. So the problem is not exactly with the code, but rather, it is something to do with the new setup on the new server.

Answers (6)


Florian Klein answers:

As said above, first check the environment used in your front controller

$configuration = ProjectConfiguration::getApplicationConfiguration('contest', 'prod', false);

Then, open your config/databases.yml to check if a different database access is defined in this environement.

example with propel:

classname: DebugPDO

classname: DebugPDO
dsn: mysql:dbname=equipmoto2_test;host=localhost
class: sfPropelDatabase
dsn: mysql:dbname=equipmoto2;host=localhost

As you can see, in function of the environment selected in my front controller, the database accessed will be either <strong>equipmoto2</strong> in prod or <strong>equipmoto2_test</strong> in test environment.

Other possible solution, you maybe are sharing the same session between the two applications:

check your session config in apps/<frontend | backend>/config/factories.yml, section <strong>storage</strong>:

[[LINK href=""]]symfony ref book[[/LINK]]

If you're using sfGuard, it will try to load the user by id stored in session, but it may be inexistent in one of your databases.

Lawrence Krubner comments:

I think you are right about sharing the session data. And, the cache data. One of the problems of this kind of setup, trying to centralize the code and then share it among dozens of sites.


Ben answers:

are you using the same environment for both controllers


$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', <ENVIRONMENT>, false);

ensure <ENVIRONMENT> is set to the same for both controllers.

Lawrence Krubner comments:

This is from back.php:


$configuration = ProjectConfiguration::getApplicationConfiguration('back', 'prod', false);


this is index.php:


$configuration = ProjectConfiguration::getApplicationConfiguration('contest', 'prod', false);


Nate Flink answers:

try accessing with the dev controller back_dev.php same problem?

Is your back.php inheriting from sfGuardSecurityUser ? check /apps/back/lib/myUser.class.php for the line: class myUser extends sfGuardSecurityUser

Lawrence Krubner comments:

backend end user class:

class myUser extends sfGuardSecurityUser

Nate Flink comments:

Is it possible that you have some .htaccess rules or redirects in the apache config on one server but not the other? Check your apache config. Are you sure your looking at what you think you are?


Gert Findel answers:

I had a similar problem, but I fixed it configuring my httpd.conf and htaccess
Can you paste your virtual host config and htaccess?


Loban Rahman answers:

(1) Can you login using the dev versions of the front controllers? contest_dev.php and back_dev.php
(2) If the same problem as above, please post the tail end of the log file.


José Nahuel Cuesta Luengo answers:

Have you checked the dsn configuration that shows up in the web debug bar for both controllers?

I mean, try accessing through the 'dev' environment on both of the controllers, and look for the DSN configuration in the web debug on both. Do they differ?