学习laravel遇到的一些坑,备忘。
项目 | 版本 |
---|---|
system | debian8 |
apache | 2.4.10 |
php | 5.6.30-0 |
mariadb | 10.0.30 |
laravel | 5.4.19 |
坑
不能使用.env
文件的配置项
已配置好.env
中的数据库,然而执行数据库迁移命令时,依然采用默认数据库配置。
在项目根目录执行命令,生成秘钥
php artisan key:generate
缺少mcrypt组件
There is no suitable CSPRNG installed on your system
安装mcrypt组件即可
sudo apt-get install php5-mcrypt
sudo service apache2 restart
多主键Model
参考Laravel Model with Two Primary Keys update [duplicate]
给路由分组设置默认Guard
修改Api\Controller
public function __construct()
{
// We set the guard api as default driver
auth()->setDefaultDriver('api');
}
参考Setting the default guard on a route group