Welcome Guest, Not a member yet? Register   Sign In
How to pull routes in spark command
#1

(This post was last modified: 03-28-2023, 04:25 PM by ciUser43.)

Previously up to version 4.2.12 I can call
PHP Code:
route_to('route_name'
and get the routes that I configured in the
PHP Code:
\app\Config\Routes.php 
, but since I upgraded to version 4.3.2 it seems that this is no longer possible due to the spark command not even including the Routes.php file.

I mainly used the command to send automated email with the link to a page in the application, and using the route_to function was a simple way to keep track of the routes.
Any suggestion on how to do this now in 4.3.2?
I don't recall in the upgrade instruction there was any information on how to do this.


Thanks.

After a quick check it seems that I can call "Services::routes()->loadRoutes();" and that loads all my custom routes in the spark command.

But not sure if that's the correct approach.
Reply
#2

See https://codeigniter.com/user_guide/insta...le-changes
Reply
#3

(03-28-2023, 05:07 PM)kenjis Wrote: See https://codeigniter.com/user_guide/insta...le-changes

Do you mean I should add likeĀ 

PHP Code:
require_once(SYSTEMPATH 'Config/Routes.php'
into all my commands?

Or are you saying spark commands aren't meant to access the routes at all? That would be strange if the support was provided and just suddenly broken without explanation.
Reply
#4

(This post was last modified: 03-28-2023, 09:25 PM by kenjis.)

Sorry, I confused it with some kind of issue where the files were not updated enough.
Reply
#5

(This post was last modified: 08-25-2023, 09:03 AM by yassine.)

Hey @kenjis, I'm having the same issue: route_to stopped working in spark commands from v4.3

I'm wondering if this was fixed in newer versions. Or is there any other way to access named routes in spark commands?

Also, thank you for your work on CodeIgniter!


EDIT: saw that @ciUser43 found a way to load routes using:

PHP Code:
Services::routes()->loadRoutes(); 
Reply
#6

"php spark routes" is one way I came across in documentation to see the routes configured. Not sure if it will help in your situation,
Reply
#7

Yes, you need to load the routes with Services::routes()->loadRoutes() now.

Maybe route_to() should load the route, though.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB