- Add your code to /src folder
<?php
namespace Acme;
class Foo
{
public static function world()
{
return 'Hello World, Composer!';
}
}
?>
- Add autoload field to composer.json
{
"require": {
"monolog/monolog": "1.0.*",
"facebook/php-sdk": "3.2.3",
"facebook/webdriver": "1.6.0",
"facebook/php-sdk-v4": "5.5.0"
},
"autoload": {
"psr-4": {"Acme\\": "src/"}
}
}
- composer install, create new autoload.php
- Use your own library
<?php
require __DIR__ . '/vendor/autoload.php';
use Acme\Foo;
echo Foo::world();
?>