laravel 尝试查看页面时出错,出现以下错误:Action Facade\Ignition\Http\Controllers\ShareReportController not defined
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58172361/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error when trying to view page, following error: Action Facade\Ignition\Http\Controllers\ShareReportController not defined
提问by Michael Guimaraes
I am getting the error below when trying to access the route, but the controller is needed to load the data:
尝试访问路由时出现以下错误,但需要控制器来加载数据:
(1/1) InvalidArgumentException
Action Facade\Ignition\Http\Controllers\ShareReportController not defined.
I am using Tenancy/Multi-Tenant package and I have configured it to use routes/tenants.php to load routes specifically for tenants. If I do the following in the tenants.php file, it returns the proper response.
我正在使用 Tenancy/Multi-Tenant 包,并且我已将其配置为使用 routes/tenants.php 专门为租户加载路由。如果我在 tenants.php 文件中执行以下操作,它会返回正确的响应。
Route::get('/test', function() {
return 'Test success';
});
though when I try to do the same, but loading the data from a controller such as this:
虽然当我尝试做同样的事情时,但是从这样的控制器加载数据:
Route::get('/testt', 'TenantController@testt');
It will show the error:
它会显示错误:
(1/1) InvalidArgumentException
Action Facade\Ignition\Http\Controllers\ShareReportController not defined.
If i try to put the same code in web.php routes, then it works perfectly. What could be the problem? Is it something in my code? Can it be because of the multi-tenant package i'm using? How would i go about further debugging this?
如果我尝试将相同的代码放在 web.php 路由中,那么它可以完美运行。可能是什么问题呢?它在我的代码中吗?可能是因为我使用的多租户软件包吗?我将如何进一步调试这个?
回答by Arnoldas
Try composer dump-autoload -o
it helped for me.
试试看composer dump-autoload -o
对我有帮助。
回答by Michael Guimaraes
The fix was to group the routes in tenants.php
with the web middleware and a namespace:
解决方法是将路由tenants.php
与 Web 中间件和命名空间组合在一起:
Route::middleware('web')->namespace('App\Http\Controllers')->group(function() {
//Routes
});
回答by Eric Lagarda
After some minutes trying to fix I found the solution.
在尝试修复几分钟后,我找到了解决方案。
You don't need to group the routes if you've done in RoutesServiceProvider or in a custom Provider.
如果您已在 RoutesServiceProvider 或自定义 Provider 中完成,则无需对路由进行分组。
Just go to config/tenancy.php
and go to routes -> path
, Remove the base_path()
function and let the string:
只需转到config/tenancy.php
并转到routes -> path
,删除base_path()
函数并让字符串:
'path' => base_path('routes/tenants/tenants.php'),
to
到
'path' => 'routes/tenants/tenants.php',
And this error should be fixed.
这个错误应该被修复。
回答by Pawan Verma
Can you see if your routes are cached and try clearing that cache. Just clear project route-cache using route:clear
您能否查看您的路由是否已缓存并尝试清除该缓存。只需使用清除项目路由缓存route:clear
回答by Nicolas Castro
I had a similar error after install laravel/passport 8.1 in Laravel 6.2:
在 Laravel 6.2 中安装 laravel/passport 8.1 后,我遇到了类似的错误:
Action Facade\Ignition\Http\Controllers\ExecuteSolutionController not defined.
Action Facade\Ignition\Http\Controllers\ExecuteSolutionController 未定义。
Fixed it runnig composer update
. The result was:
修复它运行composer update
。结果是:
Updating facade/ignition (1.13.0 => 1.13.1):
更新外观/点火(1.13.0 => 1.13.1):
回答by Aaron Bell
For people finding this via Google: I had a similar error with Laravel 6.5. I had messed up my AppServiceProvider with an incomplete Git merge:
对于通过 Google 发现此问题的人:我在 Laravel 6.5 中遇到了类似的错误。我用不完整的 Git 合并弄乱了我的 AppServiceProvider:
<?php
namespace App\Providers;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
<<<<<<< HEAD
Blade::if(
'iscurrentroute',
function ($route) {
$route = Str::replaceFirst(Request::getSchemeAndHttpHost().'/', '', $route);
return Request::is($route);
}
);
=======
Blade::component('components.sortable', 'sortable');
>>>>>>> feature/WLI-58-bedrijf-beheren
}
}
Deleting the "='s", "<'s", and ">'s", and the double use of Blade fixed it for me.
删除“='s”、“<'s”和“>'s”,Blade 的双重使用为我修复了它。
回答by CodeToLife
on server side I went to /stoage folder and cleared cashs. E.g. views folder inside that /storage. Then additionally changed all entire folders' and files' permissions to can read and write. Then pages started show up as expected
在服务器端,我去了 /stoage 文件夹并清除了现金。例如,/storage 中的视图文件夹。然后另外将所有整个文件夹和文件的权限更改为可以读写。然后页面开始按预期显示