Welcome Guest, Not a member yet? Register   Sign In
Can we use $router->getRoutes("*")
#1

can we use $router->getRoutes("*") to get all defined routes instead of $router->getRoutes()
because I notices that if we run $router->getRoutes() while we are in POST it will only return the post routes  only not all routes.
and also I notices that using

PHP Code:
$router Services::routes();
dd($router->getRoutes("*")); 
 
will return nothing (array size of 0);

I see the default value in codeigniter4/framework/system/Router/RouteCollection.php line  190-195  like this:
PHP Code:
  /**
    * The current method that the script is being called by.
    *
    * @var string HTTP verb (lower case) like `get`,`post` or `*`
    */
    protected $HTTPVerb '*'
Reply
#2

(10-15-2023, 07:39 AM)mshannaq Wrote: can we use $router->getRoutes("*") to get all defined routes instead of $router->getRoutes()

No, as you see the code, the method is not for the purpose.

For what do you want to get all defined routes?
Reply
#3

See https://forum.codeigniter.com/showthread...#pid413266
Reply
#4

(10-15-2023, 06:24 PM)kenjis Wrote:
(10-15-2023, 07:39 AM)mshannaq Wrote: can we use $router->getRoutes("*") to get all defined routes instead of $router->getRoutes()

No, as you see the code, the method is not for the purpose.

For what do you want to get all defined routes?

I am planning to store string on database , and I want to make sure that string is nod already one of defined routes before storing it into the database.

see this function https://github.com/Extendy/SmartyURL/blo...hp#L42-L60
Reply
#5

See system/Router/DefinedRouteCollector.php.
It is the class for the `spark routes` command.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB