Is it possible to override package view from another package?
When you register a view path vialoadViewsFrom('path/to/views', 'package')
it will also look in/resources/views/vendor/package
So you can override a view when using a package,
but is there a way to override a view within a different package?
Yes it is.
Steps:
Publish the package views you want to override:
php artisan vendor:publish --provider="Another\\Package" --tag=views
Modify the published ones.
Place the modifications in a dir in your package, eg:
/resources/vendor/another-package/views
Make it available for publishing. Add to your package's service provider boot():
public function boot() { $this->publishes([ __DIR__.'/resources/vendor/another-package/views' => base_path('resources/views/vendor/another-package') ], 'views'); }
Publish the modifications:
php artisan vendor:publish --provider="Your\\Package" --tag=views --force
Note: change Another\\Package
and another-package
as necessary. Works well in Laravel 7.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.