如何调用内部路由?
How to call internal route?
假设我在名为 foo.php
的文件中为 /test
声明了一个 API
路由,我如何从另一个文件访问此路由 /test
?
示例(foo.php):
$app->get('/test', function (Request $request, Response $response, array $args)
{
});
我想从 test.php
访问这条路线,我该怎么做?
与其拥有一个非常大的 foo.php
文件,不如拥有几个更小的文件,这样可以更轻松地构建更大的应用程序。
test.php
$app = new Slim();
require 'foo.php';
$app->run();
foo.php
$app->get('/test', function (Request $request, Response $response, array $args)
{
return 'Hello World!';
});
假设我在名为 foo.php
的文件中为 /test
声明了一个 API
路由,我如何从另一个文件访问此路由 /test
?
示例(foo.php):
$app->get('/test', function (Request $request, Response $response, array $args)
{
});
我想从 test.php
访问这条路线,我该怎么做?
与其拥有一个非常大的 foo.php
文件,不如拥有几个更小的文件,这样可以更轻松地构建更大的应用程序。
test.php
$app = new Slim();
require 'foo.php';
$app->run();
foo.php
$app->get('/test', function (Request $request, Response $response, array $args)
{
return 'Hello World!';
});