How to autoload a directory in Silex

If I have a directory of class files in / src / lib and I want them to be automatically loaded, how can I do this with the latest version of Silex.

I really do not see any good documents that download services.

+4
source share
1 answer

Silex startup is handled by composer . Documentation The autoload documentation details about autoload capabilities.

It is recommended that you use the psr-0 name scheme for your files. But if you do not want to do this, you can also use classmap autoload.

Here's an example with PSR-0 if the class Foo\Bar is in src/Foo/Bar.php :

 { "autoload": { "psr-0": { "Foo": "src/" } } } 

For a class map, see the documentation above.

+8
source

Source: https://habr.com/ru/post/1433193/


All Articles