тонкое исключение не уверен, что не так - PullRequest
0 голосов
/ 26 мая 2020

Я использую slim 4, а URL-адрес, который я использую: http://localhost/MyApi/public/hello/WeAreLearningPHP

Подробности

Тип: Slim \ Exception \ HttpNotFoundException Код: Сообщение 404: не найдено. Файл: /Applications/XAMPP/xamppfiles/htdocs/MyApi/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php Строка: 91

Trace 0 / Applications / XAMPP / xamppfiles / htdocs / MyApi / vendor / slim / slim / Slim / Middleware / RoutingMiddleware. php (57): Slim \ Middleware \ RoutingMiddleware-> performRouting (Object (Slim \ Psr7 \ Request))

1 / Applications / XAMPP / xamppfiles /htdocs/MyApi/vendor/slim/slim/Slim/MiddlewareDispatcher.php(132): Slim \ Middleware \ RoutingMiddleware-> процесс (Object (Slim \ Psr7 \ Request), Object (Slim \ Routing \ RouteRunner))

2 /Applications/XAMPP/xamppfiles/htdocs/MyApi/vendor/selective/basepath/src/BasePathMiddleware.php(52): class@anonymous-> дескриптор (Object (Slim \ Psr7 \ Request))

3 /Applications/XAMPP/xamppfiles/htdocs/MyApi/vendor/slim/slim/Slim/MiddlewareDispatcher.php(132): Selective \ BasePath \ BasePathMiddleware-> процесс (Object (Slim \ Psr7 \ Request ), Объект (class@anonymous))

4 / Приложения / XAMPP / xamppfiles / htdocs / MyApi / vendor / slim / slim / Slim / Middleware / ErrorM iddleware. php (89): class@anonymous-> дескриптор (Объект (Slim \ Psr7 \ Request))

5 / Applications / XAMPP / xamppfiles / htdocs / MyApi / vendor / slim / slim / Slim / MiddlewareDispatcher. php (132): Slim \ Middleware \ ErrorMiddleware-> process (Object (Slim \ Psr7 \ Request), Object (class@anonymous))

6 / Applications / XAMPP / xamppfiles / htdocs / MyApi / vendor / slim / slim / Slim / MiddlewareDispatcher. php (73): class@anonymous-> handle (Object (Slim \ Psr7 \ Request))

7 / Applications / XAMPP / xamppfiles / htdocs / MyApi / vendor / slim / slim / Slim / App. php (208): Slim \ MiddlewareDispatcher-> handle (Object (Slim \ Psr7 \ Request))

8 / Applications / XAMPP / xamppfiles / htdocs /MyApi/vendor/slim/slim/Slim/App.php(192): Slim \ App-> handle (Object (Slim \ Psr7 \ Request))

9 / Applications / XAMPP / xamppfiles / htdocs / MyApi / public / index. php (28): Slim \ App-> run ()

10 {main}

-------- -------- индекс. php -------------------

<?php

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

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

$app = AppFactory::create();

// Add Slim routing middleware
$app->addRoutingMiddleware();

// Set the base path to run the app in a subdirectory.
// This path is used in urlFor().
$app->add(new BasePathMiddleware($app));

$app->addErrorMiddleware(true, true, true);

// Define app routes
$app->get('/', function (Request $request, Response $response) {
    $response->getBody()->write('Hello, World!');
    return $response;
})->setName('root');

// Run app
$app->run();
...