asm89 / twig-cache-extension

The missing cache extension for Twig. Caching template fragments with Twig.
MIT License
388 stars 27 forks source link

Add namespace prefix #53

Closed odan closed 4 years ago

odan commented 4 years ago

Empty namespace cause troubles in some situtations and is not good for performance.

The PR adds the missing namespace prefixes.

More details: #52

oradwell commented 4 years ago

Current issue in composer autoload:

// autoload_psr4.php @generated by Composer

return array(
    'Adyen\\' => array($vendorDir . '/adyen/php-api-library/src/Adyen'),
    '' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
);

See: https://getcomposer.org/doc/04-schema.md#psr-4

Under the psr-4 key you define a mapping from namespaces to paths, relative to the package root. When autoloading a class like Foo\Bar\Baz a namespace prefix Foo\ pointing to a directory src/ means that the autoloader will look for a file named src/Bar/Baz.php and include it if present. Note that as opposed to the older PSR-0 style, the prefix (Foo\) is not present in the file path.

From what I understand this repository is not following PSR-4. For it to follow PSR-4, "Asm86" should not be in the path. You should probably switch to PSR-0, if you want to avoid directory structure change

For the changes in this PR to be compatible with PSR-4, the directory structure should be the following:

src/
- Twig/
  - CacheExtension/
test/
- Twig/
  - CacheExtension/
    - Tests/