2016-08-29 15:18
浏览 106

Composer和Linux生产服务器 - 自动加载不起作用

I have already tried searching for this question and seen a couple of answers, but no luck...

I have composer installed with Slim Framework v3.

I am using autoload for my files using PSR-4 in the composer.json file like this:

"autoload": {
 "psr-4": {
   "App\\": "App"

And this is my folder structure:

enter image description here

I am running it on a localhost Mac OS X El-Capitan using Apache 2.4 and everything works like magic. But when I upload it to my Production Linux server (also with Apache 2.4), the autoload seems to be extremely confused and I am getting errors like these:

Warning: include(/home/friendsapp/public_html/vendor/composer/../../app/Middleware/AuthMiddleware.php): failed to open stream: No such file or directory in /home/friendsapp/public_html/vendor/composer/ClassLoader.php on line 412

Warning: include(): Failed opening '/home/friendsapp/public_html/vendor/composer/../../app/Middleware/AuthMiddleware.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/friendsapp/public_html/vendor/composer/ClassLoader.php on line 412

Fatal error: Class 'App\Middleware\AuthMiddleware' not found in /home/friendsapp/public_html/public/index.php on line 5

I have namespaced my classes exactly according to my folder structure.


namespace App\Middleware;

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

use \App\Middleware\Middleware;

use \App\Share\ErrorCode;
use \App\Models\ResultMessage;

use \App\Mappers\AccessTokenMapper;

class AuthMiddleware extends Middleware {

Any help would be most appreciated! :)

图片转代码服务由CSDN问答提供 功能建议

我已经尝试过搜索这个问题并看到了几个答案,但没有运气...... </ p >

我使用Slim Framework v3安装了作曲家。</ p>

我在composer.json文件中使用PSR-4使用自动加载文件,如下所示:</ p>

“App \\”:“App”
 </ code> <  / pre> 

这是我的文件夹结构:</ p>

</ p>

我在使用Apache 2.4的本地主机Mac OS X El-Capitan上运行它,一切都像魔术一样。 但是当我将它上传到我的生产Linux服务器(也使用Apache 2.4)时,自动加载似乎非常混乱,我 我遇到这样的错误:</ p>

警告:include(/ home / friendsapp / public_html / vendor / composer /../../ app / Middleware / AuthMiddleware.php ):未能打开 n stream:第412行/home/friendsapp/public_html/vendor/composer/ClassLoader.php中没有此类文件或目录</ p>

警告:include():打开'/ home / friendsapp失败 在/ home /中包含/public_html/vendor/composer/../../app/Middleware/AuthMiddleware.php'(include_path ='。:/ usr / lib / php:/ usr / local / lib / php') 第412行的friendsapp / public_html / vendor / composer / ClassLoader.php </ p>

致命错误:/ home / friendsapp / public_html / public / index中找不到“App \ Middleware \ AuthMiddleware”类。 php在第5行</ p> </ blockquote>

我已根据我的文件夹结构完全命名了我的类。</ p>

 &lt;?  php 
namespace App \ Middleware; 
use \ Psr \ Http \ Message \ ServerRequestInterface as Request; 
use \ Psr \ Http \ Message \ ResponseInterface as Response; 
use \ App \ Middleware \ Middleware; 
use \ App \ Share \ ErrorCode; 
use \ App \ Models \ ResultMessage; 
use \ App \ Mappers \ AccessTokenMapper; 
class AuthMiddleware扩展中间件{
 </ code> </ pre> 
 \  n 

任何帮助 非常感谢! :)</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题