Last active
July 12, 2022 19:25
-
-
Save GromNaN/45ec2f622c8165e9aaa417a55bdd95e2 to your computer and use it in GitHub Desktop.
Autoload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"autoload": { | |
"psr-4": { | |
"App\\": "./" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
class Foo | |
{ | |
} | |
class Bar | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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