架设laravel

用laravel 架设的用户单点登录授权系统,git clone项目文件后,需要下面的方法初始化,纪录以供项目成员参考 

错误信息:`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 17

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`

原因:网站根目录下缺少vendor这个存放laraver依赖包的目录 

解决方法:使用composer install进行安装(以前安装过的话使用:composer update) 

只出现一行Whoops, looks like something went wrong

解决:config/app.php 修改:'debug' => true

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

解决:网站所在目录下执行命令 php artisan key:generate
将生成的key复制到config/app.php的APP_KEY键值。

然后mysql连接出错,没有配置数据库,

解决:添加.env文件,配置其中mysql 再执行导入数据库命令:php artisan migrate --path=database/migrations

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只可以有一个
posted @ 2015-10-16 19:09  facewater  阅读(417)  评论(0编辑  收藏  举报