infinum / eightshift-libs

Library that is meant to be used inside Eightshift Boilerplate and Eightshift Boilerplate Plugin libs via composer in order to be able to easily set up a modern development process.
https://eightshift.com
MIT License
61 stars 10 forks source link

LoadMore route is copied into projects in a PSR-4 noncompliant way #340

Closed mbmjertan closed 1 year ago

mbmjertan commented 2 years ago

Describe your bug

When you use npx create-wp-project with the Eightshift Libs branch set to develop, the LoadMoreRoute example class is copied over to src/Rest/Routes/LoadMoreRoute.php (while it's in Libs as src/Rest/Routes/LoadMore/LoadMoreRouteExample.php), resulting in it having the namespace ProjectName\Rest\Routes\LoadMore, but without accounting for that in the path.

This results in a PSR-4 noncompliance exception, and might be related to 89ea1b7a47fdcccbf66ba447b185950d2ff97f28.

Steps to Reproduce

  1. Create a project from the develop branch
  2. Use wp boilerplate init all or otherwise pull the class into your project using wp boilerplate
  3. Your site should be broken with a PSR-4 noncompliance exception

Expected behavior

Site shouldn't be broken with a PSR-4 noncompliance exception 😄

Screenshots, screen recording, code snippet

No response

Environment info

PHP 7.4.30, Libs on develop

Please confirm that you have searched existing issues in this repo.

Yes

Please confirm that you have searched in our documentation and couldn't find the answer.

Yes

Please confirm that your bug occurs with all plugins uninstalled and with the default WordPress theme active.

Yes

dingo-d commented 2 years ago

Can you make a PR with a fix? This shouldn't be a difficult fix to make 🙂

mbmjertan commented 2 years ago

Of course. Which approach would you prefer here? Reverting the namespace as it was previously or fixing it so it both works and looks good?

dingo-d commented 2 years ago

I'd fix it so that the path is correct. The file should be in the directory.

This would be a good way to approach routes in general - bunch them based on the functionality ('domain'). That way you can have different functionality for, for instance, GET, POST, PUT routes in the same directory.

iruzevic commented 1 year ago

quick for now I will revert back to review this in the future release

dingo-d commented 1 year ago

quick for now I will revert back to review this in the future release

What is quick? XD

Not sure why the issue is closed if it's not fixed 😬

iruzevic commented 1 year ago

I made a quick hack, wrote a reply here, than felt guilty and fixed it the right way. So this is fixed the right way 😉