今天遇到问题验证码出不来,最后找到原因是因为gregwar/captcha和mews/captcha的路由有冲突,修改mews/captcha的源码:
文件位置在:vendor/mews/captcha/src/CaptchaServiceProvider.php
修改代码如下:
// HTTP routing
if (strpos($this->app->version(), 'Lumen') !== false) {
$this->app->get('captcha[/api/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptchaApi');
$this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha');
} else {
if ((double) $this->app->version() >= 5.2) {
$this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi')->middleware('web');
// Vendor 源码修改:发现这里的优先级比 routes 下的优先级高,把 config 的可选条件去掉
// $this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
$this->app['router']->get('captcha/{config}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
} else {
$this->app['router']->get('captcha/api/{config?}', '\Mews\Captcha\CaptchaController@getCaptchaApi');
$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha');
}