HTTP routing 可以动态添加吗?一起来看看
看了一个第三方'Mews\Captcha的库,其中provider这么写的
// HTTP routing
if (strpos($this->app->version(), 'Lumen') !== false) {
$this->app->get('captcha[/{config}]', 'Mews\Captcha\LumenCaptchaController@getCaptcha');
} else {
if ((double) $this->app->version() >= 5.2) {
$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha')->middleware('web');
} else {
$this->app['router']->get('captcha/{config?}', '\Mews\Captcha\CaptchaController@getCaptcha');
}
}
疑问是:发布之后,web下面的web.php并没有新增路由配置。事实上,路由(captcha/{config?})生效了,如何做到的呢?
推荐文章: