slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

Fatal errors in PHP logs with clean install #3173

Closed daviddoyen closed 2 years ago

daviddoyen commented 2 years ago

PHP is logging errors but the page is showing when Slim is installed via : composer require slim/slim:"4.*"

<?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require __DIR__ . '/../vendor/autoload.php';

$app = AppFactory::create();

$app->get('/', function (Request $request, Response $response, $args) {
    $response->getBody()->write("Hello world!");
    return $response;
});

$app->run();
Thu Mar  3 17:36:21 2022] PHP Fatal error:  Uncaught Slim\Exception\HttpNotFoundException: Not found. in /Users/daviddoyen/Sites/testapp/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php:91
Stack trace:
#0 /Users/daviddoyen/Sites/testapp/vendor/slim/slim/Slim/Routing/RouteRunner.php(72): Slim\Middleware\RoutingMiddleware->performRouting(Object(GuzzleHttp\Psr7\ServerRequest))
#1 /Users/daviddoyen/Sites/testapp/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\RouteRunner->handle(Object(GuzzleHttp\Psr7\ServerRequest))
#2 /Users/daviddoyen/Sites/testapp/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle(Object(GuzzleHttp\Psr7\ServerRequest))
#3 /Users/daviddoyen/Sites/testapp/vendor/slim/slim/Slim/App.php(199): Slim\App->handle(Object(GuzzleHttp\Psr7\ServerRequest))
#4 /Users/daviddoyen/Sites/testapp/public/index.php(17): Slim\App->run()
#5 {main}
  thrown in /Users/daviddoyen/Sites/testapp/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php on line 91
[Thu Mar  3 17:36:21 2022] [::1]:60643 Closing

Page is showing 'Hello World!" in the browser, .htaccess is fine and public/ is the root folder. Tested in XAMPP and with built-in PHP server

cd [my-app-name]; php -S localhost:8080 -t public public/index.php

Can't reproduce it with the Slim-Skeleton.

daviddoyen commented 2 years ago

Ok, i'm just dumb af... It was the favicon.ico...