我正在Laravel 5.2架構和運行第一次項目錯誤 - 必需的引導/../供應商/ autoload.php)的index.php線22在Laravel 5
當運行根鏈接顯示錯誤:
Warning: require(/home/ubuntu/workspace/../bootstrap/autoload.php): failed to open stream: No such file or directory in /home/ubuntu/workspace/index.php on line 22 Call Stack: 0.0028 236248 1. {main}() /home/ubuntu/workspace/index.php:0 Fatal error: require(): Failed opening required '/home/ubuntu/workspace/../bootstrap/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/index.php on line 22 Call Stack: 0.0028 236248 1. {main}() /home/ubuntu/workspace/index.php:0
之前,我打電話作曲家安裝
它我應用/ .htpaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
routes.php文件
Route::get('/', function() {
return view('welcome');
});
應用/ index.php的
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
編輯:
在我的index.php替換以
require __DIR__.'/../vendor/autoload.php';
但顯示錯誤:
警告:要求(/家/ Ubuntu的/工作區/../供應商/ autoload.php):未能打開流:在/ home/Ubuntu的/工作區沒有這樣的文件或目錄/第22行的index.php調用堆棧:0.0004 233376 1. {main}()/home/ubuntu/workspace/index.php:0致命錯誤:require():無法打開所需的'/ home/ubuntu/workspace/.. /vendor/autoload.php'(include_path ='。:/ usr/share/php:/ usr/share/pear')在第22行的/home/ubuntu/workspace/index.php調用堆棧:0.0004 233376 1. { main}()/home/ubuntu/workspace/index.php:0
我在根目錄下有文件夾供應商。我如何解決這個問題?謝謝。
運行這個命令在終端: 'PHP人員明確compiled', '作曲家install', '作曲家update', '作曲家轉儲autoload'。 – Ali
自動加載文件位於'vendor'文件夾中。試試'require __DIR __。'/ ../vendor/autoload.php';'。 – Repox
我改爲__DIR __。'/ ../vendor/autoload.php'。錯誤:需要打開失敗'/home/ubuntu/workspace/../vendor/autoload.php'(include_path ='。:/ usr/share/php:/ usr/share/pear') – dev85