1

In my web application some of my application is in symfony and some is in non symfony.

As a result there are multiple database connection files (say database connections files one of which is a yml file and other is a php file.)

I am thinking to create a table and store database connection in this table and then create config files from them.

Is there any other approach for this.

2
  • What is your problem and what have you tried. Commented Apr 4, 2013 at 5:32
  • Problem is i have two files that store database connection --->one is in php (non symfony) and other in symfony(symfony) so i need to maintain connections in 2 files. To solve this i am thinking to add connection in the table and then create config files from them. Commented Apr 4, 2013 at 5:37

1 Answer 1

1

You should keep the databases.yml and load it from your non symfony application.

Inside your non symfony application, you can use the Yaml component from Symfony 2:

use Symfony\Component\Yaml\Parser;

$yaml     = new Parser();
$database = $yaml->parse(file_get_contents('/path/to/config/databases.yml'));

Or you can use sfYaml (copy/paste it insid your non-symfony project) and load the yml like this:

// if you don't use an autoload
require_once('/path/to/config/sfYaml.class.php');

$database = sfYaml::load('/path/to/config/databases.yml');
Sign up to request clarification or add additional context in comments.

3 Comments

thanx for solution Some doubt : (1)Is table solution is not gd enough(unsafe) (2)since connection of both local test and live servers are different so we ourself need to make sure, this file need to be changed before gng live
What do you mean by table solution? About local & live connection, you should handle the dev/all/prod environment on the non-symfony application (which allow you to define different parameters for each env).
it means i need to maintain databases.yml different for dev/prod/test. which means i need to remember everytime someone commits these files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.