-
-
Notifications
You must be signed in to change notification settings - Fork 549
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
Introduce auto-registration for addons #6922
Introduce auto-registration for addons #6922
Conversation
Also, ensure action classes actually extend the Action base class.
Also deal with the case where the folders don't exist
This reverts commit 371e7b8.
I can't find any existing tests for the |
Looks great, but are there some benchmarks run? Because checking all files on every request seems like a thing that would slow down large websites quite a bit? |
I like the idea a lot, but am concerned regarding the performance as well. Wouldn't this be a perfect case for some similar approach like the "@php artisan package:discover --ansi" command, executed as composer This would mean to only read files if updating, installing etc. via composer., which then creates a caching file inside the Loading the cached bootstrap file should be really fast and still add the suggested approach to auto register everything inside any addon. |
Yes, those are fair points. Performance wasn't something I thought about when making the PR. I'll make this PR a draft and see if I can do something similar to how Laravel handles it (with caching stuff in the |
I really don't want to add this precisely because of the constant file IO others have brought up. I'm going to close this for now but feel free to reopen if you come up with something more performant. Thanks for understanding. |
Maybe when we build the Addon manifest file, a cache/manifest can also be created for all the files Duncan is auto-registering? Then it would only be happening once on install, not per-request. |
Hmm, the only issue I can see with that is that what happens when you create a new tag/modifier/etc class without running the |
Well it's an addon, so any changes you make in an addon are going to need to be composer updated, so the addon manifest will get recreated. Of course, this won't be the case if you've symlinked an addon into your app for development purposes, but then you could manually run Your thoughts, @jasonvarga? |
During development of the addon it'll be a pain. You'll need to remember to run the command if you add a new thing. The effort in doing that is about the same as just adding a line to your service provider. |
This pull request implements statamic/ideas#88 and statamic/ideas#523. It introduces auto-registration for things in addon service providers.
Supported things
As long as the folder structure convention is followed, any things will be automatically registered.
src/Actions
)src/Tags
)src/Scopes
)src/Fieldtypes
)src/Modifiers
)src/Widgets
)src/Forms/JsDrivers
)routes/web.php
,routes/cp.php
,routes/actions.php
)src/UpdateScripts
)Unsupported things
There are still a few bits & pieces which will need to be registered manually after this PR.