add a library to silex

Viewed 3019

I know this question has already been asked, but it seems that autoloading process changed a little bit with composer.

I just want to add a class library to my silex project.

So I made this file: vendor\lib\picture.php

<?php
namespace MyNamespace;

class Picture
{
    function testage()
    {
        echo 'hihaaa ça marche'; exit;
    }
}

in vendor/composer/autoload_namespaces.php, I added this line to the big array:

'MyNamespace' => $vendorDir . '/lib/',

And in the main file I added:

use MyNamespace\Picture as Picture;

and called it like that:

$app->register(new Picture());

which gives me this error:

Fatal error: Class 'MyNamespace\Picture' not found...

I just don't know how to add a class that I can use from any controller, easily, without command line (I don't use composer, I downloaded silex preconfigured), any idea?

3 Answers
Related