Ask your Symfony questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How do I get the sfYaml functionality in code outside of Symfony? Symfony

I'm working on the chat software. For the sake of speed, all of the database calls are raw, pure sql, using built-in PHP functions like mysql_query(). The software lives in a directory that is in the same root directory where a Symfony project is. I want to get info from the yaml files in the Symfony system, files such as databases.yml and app.yml.

Fabien Potencier has written about making the Symfony components easy to include in projects outside of Symfony. How is this done?

The Symfony project is version 1.2.5

Answers (4)


Nate Flink answers:


Jakub Zalas answers:

You just need to require sfYaml class and you're ready to go!

require_once '/path/to/your/symfony/lib/yaml/sfYaml.php';

$databaseConfigFile = '/path/to/your/project/config/databases.yml';
$databaseConfig = sfYaml::load($databaseConfigFile);


JuG answers:


please refer to [[LINK href=""]][[/LINK]] for downloading, installing and using thee sfYaml component.

Shortly it's easy as :

// Download and extract somewhere sfYaml from

require_once 'path/to/sfYaml.php';

$array = = sfYaml::load('/path/to/file.yml');

Good luck,

PS : see as well those classes :


Loban Rahman answers:

If your chat application is severely tied with your symfony application (and may want to use more stuff from symfony 1.2/1.4 then just the yaml data), then use Jakub's solution. Otherwise, use the standalone Yaml component from the Symfony2 project, as JuG has said.