Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[php] Allow individual files per class #2267

Closed
mcos opened this issue Oct 19, 2016 · 2 comments
Closed

[php] Allow individual files per class #2267

mcos opened this issue Oct 19, 2016 · 2 comments
Assignees

Comments

@mcos
Copy link
Contributor

mcos commented Oct 19, 2016

It seems that the current php implementation generates multiple classes per file. Please allow an option similar to option java_multiple_files = true; to split each generated class out into its own file.

This will comply with http://www.php-fig.org/psr/psr-0/ and http://www.php-fig.org/psr/psr-4/ autoloading directive that:

The terminating class name corresponds to a file name ending in .php. The file name MUST match the case of the terminating class name.

The previous conventional protobuf implementation allowed an option (php.multifile) = true; directive, documented at https://drslump.github.io/Protobuf-PHP/protobuf-php.5.html which helped with this. Without this, users of this library who desire compliant conventional classloading will be forced to continue using v3.0.0 with a different library, such as https://github.com/stanley-cheung/Protobuf-PHP.

@dstore-dbap
Copy link

When using PHP composer as the dependency manager there is a workaround for the non working PSR-autoloader:

Remove all require_once lines from generated *.pb.php files (sed/find is your friend) and you're able to use https://getcomposer.org/doc/04-schema.md#classmap

@NicklasWallgren
Copy link
Contributor

NicklasWallgren commented Nov 23, 2016

Any progress on the PSR-4 support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants