require_once 'vendor/autoload.php'; $loader = new \Composer\Autoload\ClassLoader(); $loader->setPsr4('My\\Namespace\\', __DIR__ . '/path/to/namespace'); $loader->register(); use My\Namespace\Foo; $foo = new Foo();
require_once 'vendor/autoload.php'; $loader = new \Composer\Autoload\ClassLoader(); $loader->setPsr4('Symfony\\', __DIR__ . '/vendor/symfony/'); $loader->register(); use Symfony\Component\Console\Application; $console = new Application();In this example, we're adding the `Symfony` namespace to the autoload stack which is located in the `vendor/symfony/` directory. After registering the autoloader, we're using the `Application` class from the `Symfony\Component\Console` namespace. By looking at the examples, we can determine that the package library used in both examples is Composer\Autoload. `setPsr4` is a method of the `ClassLoader` class in this library that allows us to register namespaces for use with the class autoloader.