-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
"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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
