Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller methods are call twice on every request #96

Open
dieume-n opened this issue Jan 31, 2020 · 0 comments
Open

Controller methods are call twice on every request #96

dieume-n opened this issue Jan 31, 2020 · 0 comments

Comments

@dieume-n
Copy link

"phroute/phroute": "^2.1",

bootstrap.php

require_once "../vendor/autoload.php";

use Phroute\Phroute\RouteCollector;
use Phroute\Phroute\Exception\HttpRouteNotFoundException;
use Phroute\Phroute\Exception\HttpMethodNotAllowedException;
$router = new RouteCollector();
$router->get('/', ['App\Controllers\HomeController', 'index']);

$dispatcher = new Phroute\Phroute\Dispatcher($router->getData());
try {
    $response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
} catch (HttpRouteNotFoundException $e) {
    die(var_dump($e));
} catch (HttpMethodNotAllowedException $e) {
    die(var_dump($e));
}

echo $response;

HomeController.php

namespace App\Controllers;

class HomeController
{
    public function index()
    {
        return "Hello";
    }
}

every time i make a request to any of the endpoints, the controller method is called twice. Has anyone encounter this issue? if so, how did you solve it?

output
Capture

debug back_trace
Annotation 2020-01-31 151139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant