一、使用composer創建laravel 8
composer create-project laravel/laravel:^8.0 example-app
報錯:
COMPOSER_AUTH" does not match the expected JSON schema, this may result in errors and should be resolved:
- Boolean value found, but an object is required
在/var/www下執行 echo $COMPOSER_AUTH 返回 false
解決:
export COMPOSER_AUTH=
composer update -- 可以忽略此步驟
二、使用laravel installer
composer global require laravel/installer laravel new my-app
laravel installer 會根據php的版本安裝對應版本的laravel,但是不能指定具體的版本
在開發環境下,可以安裝laravel debugbar,方便進行調試,執行下面的命令
composer require barryvdh/laravel-debugbar --dev
開發模式下,使用debugbar,需要確保滿足以下條件:
.env的APP_DEBUG=true
把 Barryvdh\Debugbar\ServiceProvider::class, 添加到 config/app.php 的 providers 數組里。
如果想更方便的使用debugbar,可以借助laravel的facade特性實現,把 'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class, 添加到 config/app.php 的 aliases 數組里。
發布debugbar的自定義配置,執行如下命令:
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
參考資料
https://laravel.com/docs/8.x/installation