You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在000WebHost部署Laravel遇helpers.php加载失败错误求助

Laravel部署至000WebHost(PHP 8.0)遭遇致命错误

Fatal error: Uncaught Error: Failed opening required '/storage/ssd5/191/19896191/laravel/vendor/composer/../laravel/framework/src/Illuminate/Collections/helpers.php' (include_path='.:/usr/share/pear:/usr/share/php:/usr/share/pear:/usr/share/php') in /storage/ssd5/191/19896191/laravel/vendor/composer/autoload_real.php:39 Stack trace: #0 /storage/ssd5/191/19896191/laravel/vendor/composer/autoload_real.php(43): {closure}() #1 /storage/ssd5/191/19896191/laravel/vendor/autoload.php(25): ComposerAutoloaderInit77107db52e33f59325c65f41516f3a02::getLoader() #2 /storage/ssd5/191/19896191/public_html/index.php(36): require('...') #3 {main} thrown in /storage/ssd5/191/19896191/laravel/vendor/composer/autoload_real.php on line 39

为了显示错误,已在index.php开头添加以下代码:

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

部署步骤如下:

  • 压缩除public文件夹外的所有文件,同时单独压缩public文件夹;
  • 使用unzipper将压缩包解压到主机目录,得到对应文件结构;
  • 修改index.php文件,在两行代码中添加laravel/路径:
    require __DIR__.'/../laravel/vendor/autoload.php';
    
    /*
    |--------------------------------------------------------------------------
    | Run The Application
    |--------------------------------------------------------------------------
    |
    | Once we have the application, we can handle the incoming request using
    | the application's HTTP kernel. Then, we will send the response back
    | to this client's browser, allowing them to enjoy our application.
    |
    */
    
    $app = require_once __DIR__.'/../laravel/bootstrap/app.php';
    
  • 修改app/providers/AppServiceProvider.php文件:
    public function register()
    {
      $this->app->bind('path.public',function(){
      return'/public_html';
      });
    }
    
  • 清除缓存:删除bootstrap/cache中除.gitignore外的所有文件,同时在本地压缩前尝试过执行composer install、composer dump-autoload、composer update、composer update --no-scripts命令;
  • 正确配置.env文件(数据库等信息)。

仅手动修改过composer.json,添加了以下配置项:

"config": {
        "optimize-autoloader": true,
        "platform-check": false, //This line!
        "preferred-install": "dist",
        "sort-packages": true
    },

此外还尝试修改.htaccess为以下内容:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

已调整过文件夹结构,但问题仍未解决。

内容的提问来源于stack exchange,提问作者Lucas Tomic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 17:54:57