Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Routing] Load attributes from a directory following PSR-4 #47881

Closed
@derrabus

Description

@derrabus

Description

A client I'm working with uses SourceGuardian to encrypt their product before delivering it to their customers. They want to use Symfony's routing component and PHP attributes. Reading attributes from encrypted code works fine because attributes are part of the encrypted bytecode.

However, the component attempts to parse the PHP files it is supposed to extract routes from in order to find out which classes it declares:

$tokens = token_get_all(file_get_contents($file));

This of course fails in our scenario because the source code is not readable anymore. In our application, we currently work around this problem by extending AnnotationDirectoryLoader and overriding the findClass() method and constructing the class name under the assumption that the project follows PSR-4.

Parsing PHP code to gather class names in projects that follow PSR-4 feels unnecessary. In addition, the service discovery feature of the DI component also uses PSR-4 and reflection instead of parsing PHP files. I think, we should offer a PSR-4 attribute loader for the routing component and consider deprecating the PHP parsing logic.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions