Reputation: 26924
I get a slim demo, but I am not familiar to that, I can see in the routes.php
there are many route
in the file.
Left is the dir
structure, right is the routes.php
.
This is routes.php
code:
<?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', );
My requirment is easy, how can I call the /login2
or /register
functions in the broswer
such as google
or firefox
?
eg:
localhost/index.php/register
? (I test, get nothing)
If you need more infomation, please commit below the question.
My test
1)localhost/register
2)localhost/login2
EDIT: I know how to access the route
after the remind, in broswer , I use localhost/public/index.php
, I access the /
route:
Upvotes: 0
Views: 265
Reputation: 2380
In your case you can access /login2
route with following URL:
localhost/public/index.php/login2
Upvotes: 1