学习laravel遇到的一些坑,备忘。

项目版本
systemdebian8
apache2.4.10
php5.6.30-0
mariadb10.0.30
laravel5.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

参考文章