I'm building an app using Silex (the micro-framework).
As my app are growing in size and the need of using the same code in several routes rises, I want to organise everything a little more..
My idea is to create some custom classes, and then share them with my app:
$app['test'] = $app->share(function () {
require_once('../vendor/acme/src/test.php');
$testClass = new Test();
return new $testClass;
});
This actually works, but I need help with the following:
- Autoload the class with composer (the way its supposed to be done in Silex).
- Be able to use the existing Doctrine DBAL connection and methods within my class.
I hope someone can give me some tips how to get on, because I'm not finding the Silex docs very useful and I'm a beginner with both Silex and Composer.