简体   繁体   English

Symfony2-测试文件夹

[英]Symfony2 - Testing folder

I have a properly installed Symfony2 environment for my web application, which is connected to a certain mysql database. 我为我的Web应用程序正确安装了Symfony2环境,该环境已连接到特定的mysql数据库。

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". 我试图设置一个物理上分离的测试环境,以将其用作生产的“镜像”,作为生产前的测试环境,将整个项目的副本放在“ 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. 看一下parameters.ini文件。 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. 在第二个parameters.ini (testing_environment / app / config下的那个),我设置了一个不同的数据库连接,该连接将指向测试数据库。

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 . 我的计划是进入到生产环境只是把www.myproject.com/web/main和测试环境要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. 但是,由于某种原因,正在使用的数据库属性(无论是去www.myproject.com/web/main还是去www.myproject.com/testing_environment/web/main都是在production parameters.ini文件中设置的属性,导致无论我在浏览器中访问什么环境,唯一访问和修改的数据都是生产环境。

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? 测试环境是否不必指向具有不同数据库连接属性的自己的parameter.ini?

I have read Symfony2 documentation about setting different environments with different configurations, bundles and/or toolbars. 我已经阅读了Symfony2文档,该文档介绍了如何使用不同的配置,捆绑软件和/或工具栏设置不同的环境。 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. 阅读有关Symfony2环境和前端控制器的内容。 Different configurations are done by using different config files in app/config . 通过在app/config使用不同的配置文件来完成不同的app/config And different front controllers are put in web . 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. 当我复制整个Symfony文件夹时,它进入了整个app / logs和app / cache文件夹。

Deleting both folders, the cache was regenerated with the first http request and the new connection database was stored. 删除两个文件夹,将使用第一个http请求重新生成缓存,并存储新的连接数据库。

So the problem was that I didn't know that Symfony2 somehow in the cache the connection to the database. 所以问题是我不知道Symfony2在缓存中以某种方式连接到数据库。 May be, something to do with doctrine, by the way. 顺便说一句,可能与教义有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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