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

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
How do I get the sfYaml functionality in code outside of 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

Lawrence Krubner | 11/27/10 at 11:18pm Edit
Tutorial: How to assign prize money


(4) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    11/28/10
    12:54am
    Nate Flink says:

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

  • avatar
    Last edited:
    11/28/10
    6:56am
    Jakub Zalas says:

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


  • avatar
    Last edited:
    11/28/10
    12:15pm
    JuG says:

    Hi,

    please refer to http://components.symfony-project.org/yaml/ 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

  • avatar
    Last edited:
    11/30/10
    11:31pm
    Loban Rahman says:

    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.

This question has expired.





Current status of this question: Community pot



Please log in to add additional discourse to this page.





Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.