Questions tagged [fastroute]

FastRoute is a library that provides a fast implementation of a regular expression based router in PHP

25 questions
0
votes
1 answer

How can you create wildcard routes on Lumen?

Let's say I have a controller called TeamsController. Controller has following method, that returns all teams user has access to. public function findAll(Request $request): JsonResponse { //... } Then I have bunch of other controllers with the…
Firze
  • 3,939
  • 6
  • 48
  • 61
0
votes
1 answer

Optional route parameters being enforced in php Slim Framework v4

I'm using slim 4. I may be misunderstanding optional route parameters. My code is below: public function __invoke(App $app) { $app->post('/login', LoginHandler::class); $app->get('/users/{id:\d+}', UserHandler::class); } I expected /users/…
EJM76
  • 33
  • 5
0
votes
0 answers

Lumen directing all routes of specific group to *

I'm developing a website with simple landing page and a few other page such as contacts and news as front end (which uses normal PHP and lumen should be sufficient bythe way) and vuejs as backend. Trying to send all get request from '/admin/' to…
Webidew
  • 1
  • 1
0
votes
0 answers

How to pass parameters to controller in FastRoute?

I did not find anything related to Lumen (not Laravel) for passing value to controller. Is my approach wrong or am I just missing the obvious ? I want to pass a parameter to controller, not talking about the {name} in…
Naveen Niraula
  • 771
  • 10
  • 19
0
votes
0 answers

PHP no-framework-tutorial class not found

I try to build test project with PatrickLouys/no-framework-tutorial My Controllers/BaseController.php:
user137
  • 629
  • 1
  • 8
  • 20
0
votes
3 answers

PHP routing not working unless using an absolute path with index.php

With nikic/fast-route PHP package for url routing : PHP url routing doesn't work unless I specify the whole path for the route instead of just the name of the route : For example, in order to create a route for /hello-world, I have to specify the…
Maxime Bonin
  • 71
  • 1
  • 7
0
votes
1 answer

Lumen route with period

In Laravel I can simply have an route with period like so: Route::get('/foo.bar', function() { return 'Hello'; }); But in Lumen : $router->get('/foo.bar', function() { return 'Hello'; }); This always returns 404 error: The requested resource…
Hamed Kamrava
  • 12,359
  • 34
  • 87
  • 125
0
votes
1 answer

Using Dependency Injection in MVC PHP

For loading classes I use PSR-4 autoload. In my index.php I use FastRoute component. In that index.php I create $db connection and pass it to the controllers. call_user_func_array([new $class($db), $method], $vars); In the controllers I receive it…
0
votes
1 answer

Render Views from outside the Views folder in Lumen

i'm writing an API in Lumen 5.3 and i'd like to include APIDoc for my Documentation, im rendering the APIDoc files to app/API/Docs and i'd like to be able to render the index.html from this file whenever the /docs route is hit by a Get request on…
João Serra
  • 243
  • 4
  • 14
0
votes
1 answer

Slim Framework Optional Params Routes

I'm new to php and I'm using Slim Framework to develop a simple Rest Api. According to docs, Slim uses FastRoute. I have a route with optional params (vendor and quantity) like that: path/items/{id}/{name}/{price}[/{vendor}[/{quantity}]] The…
Alan Godoi
  • 657
  • 1
  • 12
  • 39
1
2