Is it possible to override package view from another package?
When you register a view path via
loadViewsFrom('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?
Asked
Active
Viewed 2,301 times
3

phper
- 307
- 2
- 12
1 Answers
0
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, e.g.:
/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.

maulanamukarom
- 11
- 1
- 1