Skip to content

Instantly share code, notes, and snippets.

@simensen
Created December 27, 2011 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simensen/1522684 to your computer and use it in GitHub Desktop.
Save simensen/1522684 to your computer and use it in GitHub Desktop.
<?php
define('USER_ID', 1);
// This sets up everything to include all of your
// dependencies. Anything in composer.json will
// be available by simply requesting the class name.
require 'vendor/.composer/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
//use Symfony\Component\ClassLoader\UniversalClassLoader;
use Collexi\ActivityService;
$app = new Silex\Application();
/**
* Doctrine DBAL
*/
$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
'db' => array(
'dbname' => 'collexi',
'user' => 'root',
'password' => '',
'host' => 'localhost',
'driver' => 'pdo_mysql'),
));
/**
* Twig
*/
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/views',
'twig.options' => array('cache' => false),
));
/**
* Collexi Services
*/
$loader = new UniversalClassLoader();
$loader->registerNamespaces(
array('Collexi' => __DIR__ . '/src/Collexi'));
$app['activity_service'] = function() {
// This will not work:
//return new ActivityService();
// This will work:
return new Collexi\ActivityService();
//
// or this would work:
//
// use Collexi\ActivityService;
// return new ActivityService();
//
// or this could work:
//
// use Collexi\ActivityService as ASAlias;
// return new ASAlias();
//
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment