lumen GET获取参数为空的路由设置
比如我想用GET方式访问地址:
http://127.0.0.1/user/参数
使用官方的路由文档是:
$app->get('user/{id}', function ($id) { return 'User '.$id;});
但是,如果id没有传值直接访问
http://127.0.0.1/user/
就会出现404错误
解决办法就是更改路由为:
$app->get('user[/{id}]', function ($id) { return 'User '.$id;});
whereHas中关联的表在另一个库的情况
Users::whereHas('posts', function($q) use ($keyword) { if($keyword){ $q->from('postsr的数据库名称.posts')->where('title','like','%'.$keyword.'%'); }})
队列处理
##后台运行队列监听
nohup php artisan queue:listen >/dev/null 2>&1 & nohup php artisan queue:work --daemon >/dev/null 2>&1 & //不重新加载整个框架,而是直接 fire 动作su apache -c -l "nohup php artisan queue:work --daemon >/dev/null 2>&1 &" //以apache用户运行sudo -u apache -s nohupphp artisan queue:listen --queue=wxmsg > /dev/null 2>&1 &