Closed markhowells closed 4 years ago
Wheb debugging the router I can see that the router is trying to match a regex
^(?|/hello/hello/([^/]+))$
which looks wrong.
Hi @markhowells I have tried the same on my machine and it works.
php -S localhost:8080 -t public
http://localhost:8080/hello/world
-> Hello, world
http://localhost:8080/users/1234
=> 400 Bad Request - Error details: [0] User not found: 1234
This is OK, the route itself is working.
Can you give me more details please.
Hey @odan
My BAD... I actually described the issue incorrectly and, I am afraid, misled you ;(
I wrote out the command line
php -S localhost:8080 -t public
When I was actually debugging using PHPStorm... and I thought that was the command line the ide was generating. I just ran it from the command-line (like you) and it worked...
It turns out I had made a mistake with the run configuration and omitted the Root Directory spec... So it looks like some kind of weirdness ensues if you do that with a route that has parameters (it works fine for non-parametized routes).
I really appreciate your work (blog, tutorials et. al.) so I'm embarrassed to have wasted your time.
PHP: 7.4 I've just created a new project using the command
However when I run it
The issue a GET against
http://localhost:8080/users/1234
orhttp://localhost:8080/hello/world
I get a route failure
404 Not Found - Error details: [404] Not found. in C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php on line 93. Backtrace: #0 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(59): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) #1 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(140): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #2 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\twig-view\src\TwigMiddleware.php(125): class@anonymous->handle(Object(Slim\Psr7\Request)) #3 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(188): Slim\Views\TwigMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #4 C:\Users\Mark\PhpstormProjects\clientservices\vendor\selective\basepath\src\BasePathMiddleware.php(52): class@anonymous->handle(Object(Slim\Psr7\Request)) #5 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(188): Selective\BasePath\BasePathMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #6 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(107): class@anonymous->handle(Object(Slim\Psr7\Request)) #7 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(188): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #8 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): class@anonymous->handle(Object(Slim\Psr7\Request)) #9 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\App.php(215): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #10 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\App.php(199): Slim\App->handle(Object(Slim\Psr7\Request)) #11 C:\Users\Mark\PhpstormProjects\clientservices\public\index.php(3): Slim\App->run() #12 {main}
The issue seems to be any route with a named parameter...