没有为 [xxx] 定义提示路径

问题描述 投票:0回答:8

我正在尝试将我的包链接到同一包中的视图。
这是文件结构:

/report/src
/report/src/ReportServiceProvider.php
/report/src/views/test.blade.php
/report/src/SomeClass.php

在我的

ReportServiceProvider.php
中,我指定了应该从其中加载视图的目录(如在此处指定):

public function boot()
{
    $this->loadViewsFrom(__DIR__.'/views', 'reports');
}

有了“提示”报告,所以我应该能够通过

view('reports::test')

访问它们

当然,我将我的 ServiceProvider 添加到

/config/app.php
的提供者数组中,如下所示:

....
Vendor\Report\ReportServiceProvider::class,
....

我在作曲家中加载我的包,如下所示:

"autoload": {
  ....
  "psr-4": {
     "App\\": "app/",
     "Vendor\\Report\\": "packages/vendor/report/src"
  }
  ...
 }

但是当我在

view('reports::test')
中使用
SomeClass.php
时,出现以下错误:

没有为[报告]定义提示路径

所以不知怎的它找不到报告提示...... 我在这里缺少什么?

php laravel-5
8个回答
9
投票

我对 Laravel 的默认忘记密码功能也有类似的问题。错误

No hint path defined for [emails]

跑步

php artisan optimize:clear
为我解决了这个问题。


4
投票

我认为report是你的包名称,

第1步:必须在服务提供者内部指定包名

$this->loadViewsFrom(__DIR__.'/views', 'report'); 

第2步:如果你想加载视图

return view('packageName::Email.testmail'); //packageName is report, the actual path to my view is package/report/src/views/Email/testmail.blade.php

2
投票

需要在cofing/app.php中添加包的服务提供者


1
投票

我通过将以下代码片段放在我的包的服务提供商

No hint path defined for [view]
方法上解决了错误
boot

$this->loadViewsFrom(__DIR__.'/views', 'home');

其中

home
是我的视图文件
home.blade.php
。由于我是 Laravel 初学者,也许在包构建类型的编码中需要提供服务提供者内视图文件的路径。


0
投票

如果您的刀片视图位于 ...views/xxx 中,则可以这样指定它:

app('xxx')->addNamespace('mail', resource_path('views') . '/xxx');

0
投票

如果您使用

infyomlabs/adminlte-templates
套餐,只需在
config/app.php
中添加服务提供商,如下所示:

'providers' => [
    // ...
    InfyOm\AdminLTETemplates\AdminLTETemplatesServiceProvider::class,
    // ...
],

0
投票

@include('cookie-consent::index') 这应该使用刀片文件 在正文标签或页脚标签中

<body>
@include('cookie-consent::index')
</body> 



<footer>
@include('cookie-consent::index')
</footer> 

@include('cookieConsent::index') /**这可能不起作用*/


0
投票

Laravel 11

我的问题是上/下:

奔跑:

php artisan down --with-secret --render="errors::503"

中和运行:

php artisan up

© www.soinside.com 2019 - 2024. All rights reserved.