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!

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

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证