Closed usernotnull closed 3 years ago
Hi there 👋
Thanks for raising this. A lot of the issue around loading the app
directory by default has been discussed in this issue https://github.com/lorisleiva/laravel-actions/issues/133#issuecomment-926428404.
That being said, you're also mentioning the ability to make this class loader more flexible to allow for external libraries to load their own actions which is interesting.
I'll keep this open to make sure it is not forgotten when issue #133 gets resolved.
The way I see it, there are two options:
In both cases, there is the issue of parsing files, which is inherently not as optimal, so caching should happen at a certain point. Of course it's less of a headache the way it's already written, but it does come with the inconveniences mentioned by this issue and #133.
Hmm I wouldn't want to add to much magic to this class name resolution. I think if a user is not going to use the default App
namespace convention, then it's okay for them to defined their own namespace resolution logic with a callback. And of course the same goes for package developers.
This has been implemented in the Lody package which is now being used by Laravel Actions to register routes and commands. This means Laravel Actions now supports registering routes and commands in any namespace — not only in the App
namespace — and even in any namespace within your vendor
directory. It uses your vendor/composer/autoload_psr4.php
file which uses the PSR-4 configurations present in your composer.json
.
This was released in v2.2.0
. 🚀
Actions::registerCommands & Actions::registerRoutes fail to import packages in vendor directory.
This is because
vendor/lorisleiva/laravel-actions/src/Util.php::getClassnameFromRealpath
's assumption for class names breaks the way it is coded when dealing with scenarios where the namespace doesn't start with app but src, as common in packages.Any plans to work on this issue from your side? I would submit a PR but it'll take a while cuz I'm swamped. I extracted some actions to a package in order to share it with multiple projects and found this issue.