Skip to content

Instantly share code, notes, and snippets.

@GromNaN
Last active July 12, 2022 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GromNaN/45ec2f622c8165e9aaa417a55bdd95e2 to your computer and use it in GitHub Desktop.
Save GromNaN/45ec2f622c8165e9aaa417a55bdd95e2 to your computer and use it in GitHub Desktop.
Autoload
{
"autoload": {
"psr-4": {
"App\\": "./"
}
}
}
<?php
namespace App;
class Foo
{
}
class Bar
{
}
<?php
require __DIR__ . '/vendor/autoload.php';
// This will not work, the class App\Bar cannot be autoloaded,
// it used to work with composer 1 when the autoload was optimized into a classmap
new App\Bar();
<?php
require __DIR__ . '/vendor/autoload.php';
// This works, the file Foo.php is required by autoloading App\Foo
new App\Foo();
new App\Bar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment