[英]Laravel won't load the Blade templates from my package
In my Laravel 5.5 application, I have created a package which is structured like so: 在我的Laravel 5.5应用程序中,我创建了一个结构如下的包:
src/
src/Providers
src/Views
(..)
The ServiceProvider for my package, located in the src/Providers
folder, registers the views using: 我的软件包的ServiceProvider位于
src/Providers
文件夹中,它使用以下方法注册视图:
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../Views', 'package');
}
Now, when trying to use any given view from that package in a main application Blade template like this... 现在,当尝试在主应用程序刀片模板中使用该包中的任何给定视图时,如下所示...
@include('package::view')
...I get the following error: No hint path defined for [package].
...我得到以下错误:
No hint path defined for [package].
According to the docs, it's supposed to work like this, though. 根据文档,它应该可以这样工作。 What am I missing?
我想念什么?
Note: The ServiceProvider is correctly added to my app.php
. 注意:ServiceProvider已正确添加到我的
app.php
。
So I found the rather trivial reason: 因此,我发现了一个不重要的原因:
Before using a View file that's being registered in a deferred package ServiceProvider, one has to make sure that the ServiceProvider has been loaded (thus also registering the View). 在使用在延迟包ServiceProvider中注册的View文件之前,必须确保已加载ServiceProvider(因此也注册了View)。
Setting the ServiceProvider to be loaded eagerly solved the problem. 设置要加载的ServiceProvider可以解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.