0

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?

j08691
  • 204,283
  • 31
  • 260
  • 272
Blackbam
  • 17,496
  • 26
  • 97
  • 150

1 Answers1

0

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!

Blackbam
  • 17,496
  • 26
  • 97
  • 150