Reputation: 554
I have a package in my Laravel project that has a view of it's own. I need to include that view in the main view of my project. My package is named as Tkabir\Somepackage. In my project's config/app.php, I have included the service provider for the package as
'providers' => [
/*
* Package Service Providers...
*/
Tkabir\Somepackage\SomeServiceProvider::class,
]
and also included alias for package's facade as
'aliases' => [
/*
*/
'Somepackage' => Tkabir\Somepackage\Facade\Somepackage::class,
]
But still, when I try to include the view from the package in my main view like this:
@include('Somepackage::welcome')
...where welcome.blade.php is the blade view file in my package, I get the following error displayed:
ErrorException in FileViewFinder.php line 112: No hint path defined for [Somepackage]. (View: E:\xampp\htdocs\laravel->projects\test_package\resources\views\welcome.blade.php)
What may seem to be the problem here?
Here's the link to my package in Github, if anyone needs to see the files: mypackage
Upvotes: 1
Views: 1995
Reputation: 679
@include
includes a view. You're calling in a method for a class.
You're including configurations correctly with
$this->publishes([
.'/Config/somepackage.php' => config_path('somepackage.php'),
], 'config');
You need to do the same thing for your views in your service provider's boot()
method for views: https://laravel.com/docs/5.3/packages#views | Header: Publishing Views
You also need to run php artisan vendor:publish
just as you would for configurations, and include your view in with @include
Take a look at the link I gave for full documentation on building packages in Laravel
Upvotes: 1