Laravel,没有Shell访问的转储自动加载 [英] Laravel, dump-autoload without Shell Access

查看:53
本文介绍了Laravel,没有Shell访问的转储自动加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个名称相同的控制器:

I have two controllers with the same name:

app\controllers\CareersController.php(供公共使用) app\controllers\Admin\CareersController.php(对于管理员)

app\controllers\CareersController.php (for public use) app\controllers\Admin\CareersController.php (for admins)

由于命名冲突,我在管理控制器中添加了namespace admin;.

Because of the naming conflict, I added namespace admin; to the admin controller.

在本地一切正常,但是当我将新的管理控制器上载到服务器时,出现错误:Class Admin\CareersController does not exist

Everything works fine locally but when I uploaded the new admin controller to my server, I get an error: Class Admin\CareersController does not exist

据我了解,解决方法是: php artisan dump-autoloadcomposer dump-autoload

From what I understand, the fix is: php artisan dump-autoload and composer dump-autoload

但是,我没有Shell权限来运行这些命令,并且服务器上也未安装composer.因此,有没有一种方法可以在没有Shell访问的情况下重新加载自动加载的文件?

However, I don't have Shell access to run those commands and composer isn't installed on the server anyway. So, is there a way to reload the auto-load file without Shell access?

推荐答案

您不需要shell访问. Artisan包含dump-autoload函数.您可以通过应用程序内的PHP调用来做到这一点:

You dont need shell access. Artisan includes a dump-autoload function. You can just it via a PHP call within your app:

Route::get('/updateapp', function()
{
    \Artisan::call('dump-autoload');
    echo 'dump-autoload complete';
});

只是注意到您写了反正没有在服务器上安装composer" .不知道会发生什么-请尝试上面的命令并告诉我们.

just noticed you wrote "composer isn't installed on the server anyway". Not sure what will happen - try the command above and let us know.

如果它不起作用-那么只需在本地运行composer dump-autoload-然后上传新的autoload.php.

If it doesnt work - then just run composer dump-autoload locally - then upload your new autoload.php.

另一方面,是否有切换服务器的选项?如果没有命令行和& ;,您将继续遇到各种问题.作曲家访问.您只需要用Forge并在DigitalOcean,Linode等服务器上启动新服务器,所需的时间就少于解决该问题所需的时间:)

As a side point - is there any option to switch servers? You going to keep running into various issues if you dont have command line & composer access. You could just use Forge and spin up a new server on DigitalOcean, Linode etc in less time than it would take to fix this issue :)

这篇关于Laravel,没有Shell访问的转储自动加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆