简体   繁体   English

将流明从5.3升级到5.4会中断路由-需要附加前缀

[英]Upgrading Lumen from 5.3 to 5.4 breaks routing - requires additional prefix

I am following the upgrade guide to get a Lumen app onto the latest version. 我正在按照升级指南将Lumen应用程序升级到最新版本。 The step up to 5.4 breaks routing in the following way. 升级到5.4将以以下方式中断路由。

There is a route at /oauth/test . /oauth/test处有一条路由。

It now results in a 404 (was fine on 5.3): http://testcase.local/oauth/test 现在,结果为404(在5.3上正常): http://testcase.local/oauth/test

It works if double-nesting the route, as follows: 如果对路径进行双重嵌套,则可以进行以下操作:

http://testcase.local/oauth/oauth/test

It is slightly more complex in that the frontend (single page JS) of the application is served behind apache, and the routes that are backend-based are symlinked in. However, apache is configured appropriately (FollowSymLinks) and the configuration worked fine in 5.3. 稍微复杂一点,因为应用程序的前端(单页JS)位于apache后面,并且基于后端的路由被符号链接。但是,apache的配置正确(FollowSymLinks),并且该配置在5.3中工作正常。

The routes list out correctly in php artisan route:list 路由在php artisan route:list正确php artisan route:list

What has changed in 5.4 to break this and how can I fix it? 5.4中有哪些更改可以解决此问题,我该如何解决?

Edit: The cause is this commit to Lumen. 编辑:原因是对流明的承诺

So something in the way symfony/http-foundation processes symlink-based paths breaks for this use case. 因此,在此用例中,symfony / http-foundation处理基于symlink的路径的方式有所中断。

Workaround was to change the logic in the below method: 解决方法是更改​​以下方法的逻辑:

class Application extends \Laravel\Lumen\Application
{
    /**
     * This override fixes our routing problem
     * https://stackoverflow.com/questions/49048199/upgrading-lumen-from-5-3-to-5-4-breaks-routing-requires-additional-prefix
     *
     * Parse the incoming request and return the method and path info.
     *
     * @param  \Symfony\Component\HttpFoundation\Request|null  $request
     * @return array
     */
    protected function parseIncomingRequest($request)
    {
        if (! $request) {
            $request = Request::capture();
        }

        $this->instance(Request::class, $this->prepareRequest($request));

        // need the base url as well as the pathinfo when coming from symlinks
        return [$request->getMethod(), '/'.trim($request->getBaseUrl() . $request->getPathInfo(), '/')];
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM