我得到了一个苗条的演示,但我对此并不熟悉,我可以在routes.php
中看到文件中有很多route
。
左边是dir
结构,右边是routes.php
。
这是routes.php
代码:
<?php
// Routes
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use LeanCloud\LeanObject;
use LeanCloud\LeanQuery;
use LeanCloud\LeanUser;
use LeanCloud\LeanACL;
$app->get('/', function(Request $request, Response $response) {
if (!array_key_exists('status', $request->getQueryParams())) {
$status = '0';
} else {
$status = $request->getQueryParams()['status'];
}
$user = LeanUser::getCurrentUser();
$query = new LeanQuery('Todo');
$query->limit(20)->addDescend('createdAt')->_include('owner');
if ($status === '0') {
$query->equalTo('done', false);
} else {
$query->equalTo('done', true);
}
$todos = $query->find();
return $this->renderer->render($response, 'index.phtml', [
'user' => $user,
'status' => $status,
'todos' => $todos,
]);
});
$app->post('/register', function(Request $request, Response $response) {
$data = $request->getParsedBody();
$user = new LeanUser();
$user->setUsername($data['name']);
$user->setPassword($data['password']);
try {
$user->signUp();
} catch (\LeanCloud\CloudException $e) {
return $this->renderer->render($response, 'register.phtml', ['error' => $e]);
}
return $response->withStatus(302)->withHeader('Location', '/');
});
//测试
$app->get('/login2', function() {
echo "login2";
});
//$app->get('/login3', );
我的要求很简单,如何调用/login2
中的/register
或broswer
函数,例如google
或firefox
?
例如:
localhost/index.php/register
? (我测试,什么都没有)
如果您需要更多信息,请在问题下方提交。
我的测试
1)本地主机/注册
2)本地主机/ Login2身份
编辑:我知道如何访问路线
提醒后,在broswer中,我使用localhost/public/index.php
,我访问了/
路线:
答案 0 :(得分:1)
在您的情况下,您可以使用以下网址访问/login2
路线:
localhost/public/index.php/login2