Re: [Pre-RFC][Discussion] Native Engine-Level PSR-4 Autoloader
| From: | fennic log | Date: | Fri, 17 Jul 2026 00:59:19 +0000 |
| Subject: | Re: [Pre-RFC][Discussion] Native Engine-Level PSR-4 Autoloader | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131988@lists.php.net to get a copy of this message | ||
Here is an example script i whipped up.
```php
// vendor/autoload.php example
spl_autoload_psr4_enable(); spl_autoload_psr4_register('Acme\\Blog\\',
__DIR__ . '/src/'); spl_autoload_psr4_register('Acme\\Blog\\Tests\\',
__DIR__ . '/tests/', prepend: true);
// Our script.php: new \Acme\Blog\Post(); // Engine (C level): // -
normalizes prefix "Acme\Blog\Tests\" first (prepend) // - no local match →
"Acme\Blog\" // - match → relative = "Post" // - candidate = src/Post.php
// - if file exists → include it (silently on failure) → if class now
defined, success else normal undefined class error. // - else fall through
to any userspace spl_autoload stack
```