Instead of manually removing and re-requiring the package, you can use the composer dump-autoload command to regenerate the Composer autoloader files and refresh the aliases without needing to re-run composer require.
Feb 8, 2025
8
Level 27
How to add an alias for blade?
- In
composer.json, we can defineextra.laravel.aliaseswhich then becomes available in blade. - However, each time I do that, I must remove and require my package again.
- Is there a way to make the alias available in blade without have to perform step 2?
- Or is there a command that I can run to "refresh" all available aliases for blade?
Level 27
I have never used @use(...) before yet all the Abcde::method1() Fghijk::method2() worked.
The command that solves the problem is php artisan package:discover, it reads from composer.json's extra.laravel.aliases and registers them.
Thanks all!
Please or to participate in this conversation.