douguai7291 2018-12-14 15:46
浏览 72
已采纳

Lumen 5.7:应用程序在视图中生成断开的链接(无故停止工作)

My complete Lumen application suddenly stopped working after one year without problems in the production system (exception on almost any page). As I did not change any code (at least not conciously) I suppose this might be an issue with background changes in the hosting environment.

It all started with a NotFoundHttpException:

(1/1) NotFoundHttpException
in RoutesRequests.php (line 226)
at Application->handleDispatcherResponse(array(0))
in RoutesRequests.php (line 164)
at Application->Laravel\Lumen\Concerns\{closure}()
in RoutesRequests.php (line 413)
at Application->sendThroughPipeline(array(), object(Closure))
in RoutesRequests.php (line 166)
at Application->dispatch(null)
in RoutesRequests.php (line 107)
at Application->run()
in index.php (line 32)

After some research I found a solution to this on SO: NotFoundHttpException with Lumen

It looked like the problem could be solved with putting:

$app->run(
    $app->make('request')
);

into index.php.

However now all of my links within the views are broken - examples:

<link rel="icon" type="image/png" sizes="96x96" href="https://:/images/app/favicon-96x96.png">
<link rel="stylesheet" href="https://:/css/base.css">

The urls are generated in Lumen/src/helpers.php:

/**
 * Generate a url for the application.
 *
 * @param  string  $path
 * @param  mixed   $parameters
 * @param  bool    $secure
 * @return string
 */
function url($path = null, $parameters = [], $secure = null)
{
    return app('url')->to($path, $parameters, $secure);
}

It seems like all parameters are passed correctly: $path is /images/app/apple-icon-57x57.png for instance while the others are empty / null.

Update: After searching for some time I have recognized that:

namespace Symfony\Component\HttpFoundation;

class Request
{
// ...

    /**
     * Gets the scheme and HTTP host.
     *
     * If the URL was called with basic authentication, the user
     * and the password are not added to the generated string.
     *
     * @return string The scheme and HTTP host
     */
    public function getSchemeAndHttpHost()
    {
        return $this->getScheme().'://'.$this->getHttpHost();
    }

// ...
}

... is delivering a wrong scheme (without SSL) and an empty host. But still I do not know why this happens.

After searching for some time I still have no idea where this might come from. Has anybody experienced a similar problem or can help me out on this?

  • 写回答

1条回答 默认 最新

  • doudi4621 2018-12-17 17:17
    关注

    After updating from Lumen 5.5 to Lumen 5.7 and updating PHP from 7.0 to 7.2.9 the problem has partly disappeared. Still I had to remove:

        $app->make('request')
    

    The solution from NotFoundHttpException with Lumen did not work in my case and there are still some Exceptions. Better solutions or explanations are still very welcome!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知