If I have a directory of class files in /src/lib and I want them autoloaded, how do I do this with the latest version of Silex.
I don't really see any good documention other that loading services.
The autoloading of silex is handled by composer. The composer documentation on autoloading goes into detail on what kinds of autoloading are possible.
It is recommended that you use a psr-0
naming scheme for your files. But if you don't want to do that, you can also use classmap autoloading.
Here's an example with PSR-0, assuming the class Foo\Bar
is in src/Foo/Bar.php
:
{
"autoload": {
"psr-0": { "Foo": "src/" }
}
}
For classmap, refer to the documentation linked above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With