架設laravel

用laravel 架設的用戶單點登陸受權系統,git clone項目文件後,須要下面的方法初始化,紀錄以供項目成員參考 php

錯誤信息:`Warning: require(/http/www.mywakavLee.cn/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /http/www.mywakavLee.cn/bootstrap/autoload.php on line 17mysql

Fatal error: require(): Failed opening required ‘/http/www.mywakavLee.cn/bootstrap/../vendor/autoload.php’ (include_path=’.:/usr/local/lib/php’) in /http/www.mywakavLee.cn/bootstrap/autoload.php on line 17`nginx

緣由:網站根目錄下缺乏vendor這個存放laraver依賴包的目錄 laravel

解決方法:使用composer install進行安裝(之前安裝過的話使用:composer update) git

只出現一行Whoops, looks like something went wrongsql

解決:config/app.php 修改:'debug' => true數據庫

No supported encrypter found. The cipher and / or key length are invalidapache

解決:網站所在目錄下執行命令 php artisan key:generate
將生成的key複製到config/app.php的APP_KEY鍵值。

而後mysql鏈接出錯,沒有配置數據庫,bootstrap

解決:添加.env文件,配置其中mysql 再執行導入數據庫命令:php artisan migrate --path=database/migrationsapp

apache .htaccess

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

nginx

location / { try_files $uri $uri/ /index.php?$query_string; }

查看命令php artisan list 

如添加controller文件 php artisan make:Controller  XxxController

開發過程常常出現NotFoundHttpException in RouteCollection.php line 143:緣由沒有正確配置路由routes.php

 添加英文語言包到resources/lang ,配置config/app.php內的

'locale' => 'zh-CN',
model字段和驗證信息翻譯成中文,
public $customeAttributes = [ 'name' => '惟一標識',
'display_name'=>'角色名',
'discription'=>'描述'
];
$this->validate($request, [
'name' => 'required|unique:roles|max:255',
'display_name' => 'required',
],[],
$this->customeAttributes);
model內的各類設定
public $table = 'permission_role';
public $timestamps = false;//不添加created_at,updated_at
//protected $fillable = ['description', 'display_name'];//開啓白名單字段,能夠更改protected $guarded = [];//保護字段,防止注入和上面的$fillable只能夠有一個
相關文章
相關標籤/搜索