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

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)

2010-11-28

Nate Flink answers:

http://lmgtfy.com/?q=php+yml+parser

2010-11-28

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);


2010-11-28

JuG answers:

Hi,

please refer to [[LINK href="http://components.symfony-project.org/yaml/"]]http://components.symfony-project.org/yaml/[[/LINK]] for downloading, installing and using thee sfYaml component.

Shortly it's easy as :


<?php
// Download and extract somewhere sfYaml from http://components.symfony-project.org/

require_once 'path/to/sfYaml.php';

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



Good luck,

PS : see as well those classes :
* http://www.symfony-project.org/api/1_4/sfYamlConfigHandler
* http://www.symfony-project.org/api/1_4/sfDatabaseConfigHandler

2010-11-30

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.