简体   繁体   中英

Symfony2 - Testing folder

I have a properly installed Symfony2 environment for my web application, which is connected to a certain mysql database.

I am trying to set a physically separated Testing Environment to use it as the pre-production testing environment as a "mirror" of production, locating a copy of the whole project in a subfolder of the "www".

Something like:

www
  |app
      |config
          |parameters.ini
  |src
  |vendor
  |web
  (...)
  |testing_environment
      |app
          |config
              |parameters.ini
      |src
      |vendor
      |web
      (...)

Take a look to the parameters.ini files. In the upper one (the one in the production environment), I have set the connection of the production database with its hostname, database name, user and password.

In the second parameters.ini (the one under testing_environment/app/config), I have set a different database connection pointing to what it will be the testing database.

My plan is to access to the production environment just putting www.myproject.com/web/main and to the testing environment going to www.myproject.com/testing_environment/web/main . One accesing each database separately.

Actually, I do get to access the testing environment, seen the testing version of my project, with its different set of directories, subdirectories and files. But, for some reason, the database properties that are being used both going to www.myproject.com/web/main and to www.myproject.com/testing_environment/web/main are the ones set in production parameters.ini file, causing that the only data accessed and modified is the production environment one, no matter what environment I am accessing in my browser.

Why this happens? Isn't it all relatively referenced? Wouldn't the testing environment have to be pointing to its own parameters.ini with its different database connection properties?

I have read Symfony2 documentation about setting different environments with different configurations, bundles and/or toolbars. But that doesn't allow to work with a different set of databases and directories/files.

What am I missing? How do I get what I need without hiring a diferent hosting for my pre-production testing works?

I'm sorry to say it, but you are doing it the wrong way. Read something about Symfony2 environments and front controllers. Different configurations are done by using different config files in app/config . And different front controllers are put in web .

Something to read:

Ok, I got it!

It was a matter of cache directories.

When I copied the whole Symfony folder, it went within it the whole app/logs and app/cache folders.

Deleting both folders, the cache was regenerated with the first http request and the new connection database was stored.

So the problem was that I didn't know that Symfony2 somehow in the cache the connection to the database. May be, something to do with doctrine, by the way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM