Visual Arts Press Blog

The all knowing, ever present VAP knowledge base

Archive for September, 2012

Using Symfony components in regular web apps

without comments

This is useful if you want to, say, use a YAML config file in your app.

Install PEAR

sudo port install php5 +pear
sudo pear channel-discover pear.symfony.com

test PEAR

Install desired Symfony components

sudo pear install pear.symfony.com/Yaml
sudo pear install pear.symfony.com/ClassLoader

testFile.php

<?php
require_once 'Symfony/Component/ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->useIncludePath(true);
$loader->registerNamespace('Symfony\Component\Yaml\Yaml','/opt/local/lib/php');
$loader->register();

$yaml = new Symfony\Component\Yaml\Yaml;

If you get no errors, then everything should be working. Can also add the following:

$queries = $yaml->parse(file_get_contents('config/queries.yml'));
print_r($queries);

download config/queries.yml

Written by ecorriel

September 26th, 2012 at 3:31 pm

Posted in admin,web