index.php中的最后一个要求仅适用于路由

时间:2017-07-04 05:27:24

标签: slim

我在SLIM中创建API,其中包含两个路径文件customers.php和books.php。 books.php路由文件工作正常,但是当我运行customers.php路由时,它说404错误。

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';
require '../src/config/db.php';

$config = [
    'settings' => [
        'displayErrorDetails' => true,
        //'determineRouteBeforeAppMiddleware' => true,
        'debug' => true 
    ],
];
$app = new \Slim\App($config);


//$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});

// Customer routes
require '../src/routes/customers.php';  //this route file does not work
require '../src/routes/books.php';  //this route file work

$app->run();

0 个答案:

没有答案