Nick
Nick

Reputation: 2922

Adding a library to Composer in Symfony 2.1+

I'm trying to add some libraries to composer.json

The libraries are located at Symfony/vendor/foo/lib/Foo/*

Before I loaded them under the registerNamespaces method in autoload.php as:

...
'Foo' => __DIR__.'/../vendor/foo/lib',
...

I have tried adding them as "foo": "*" and "foo/foo": "*" in composer.json to no avail. The documentation seems extremely lacking in this regard.

Upvotes: 3

Views: 3287

Answers (1)

KingCrunch
KingCrunch

Reputation: 131861

You have to look at Composers documentation, because the autoloading is completely taken over there. A good start to update ones Symfony 2.0 application I've used is to compare it against the current Symfony Standard. For your problem you should have a look at app/autoload.php. There you can find

$loader = @include __DIR__.'/../vendor/autoload.php'

in line 5 (within an if-expression, but thats not important here). This means, that as long as you let composer install the packages you don't have to take about the autoloading anymore. Of course you must call php composer.phar install first. If you don't know the name of the package, have a look at the packages composer.json-file, or search for it at Packagist

Upvotes: 2

Related Questions