CodeIgniter Forums
Updating ci with composer problem with shield's route - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Updating ci with composer problem with shield's route (/showthread.php?tid=92550)



Updating ci with composer problem with shield's route - pippuccio76 - 03-04-2025

HI , i have this error :
Call to a member function routes() on null
at APPPATH/Config/Routes_gestionale.php:19
 this is my Route.php :

Code:
<?php

use CodeIgniter\Router\RouteCollection;

/**
* @var RouteCollection $routes
*/

require 'Routes_vetrina.php';


require 'Routes_gestionale.php';

and this is my Routes_gestionale.php

Code:
<?php






############################################################################################################
############################################################################################################
#                                      GESTIONALE
############################################################################################################
############################################################################################################

/*
    * --------------------------------------------------------------------
    * AUTH
    * --------------------------------------------------------------------
    */
service('auth')->routes($routes); //line 19
How can isolve it ?


RE: Updating ci with composer problem with shield's route - InsiteFX - 03-05-2025

The files do not know what the $routes are, try adding this to the top of the files under <?php

PHP Code:
use CodeIgniter\Router\RouteCollection



RE: Updating ci with composer problem with shield's route - pippuccio76 - 03-05-2025

(03-05-2025, 12:54 AM)InsiteFX Wrote: The files do not know what the $routes are, try adding this to the top of the files under <?php

PHP Code:
use CodeIgniter\Router\RouteCollection

Doesn't work ...

i insert :
PHP Code:
use CodeIgniter\Router\RouteCollection
in file that require other route file...


RE: Updating ci with composer problem with shield's route - michalsn - 03-05-2025

Can't reproduce the problem. Is it working if you move the Shield routes to the main file?

Instead of using "require", you should rather use app/Config/Routing::$routeFiles array for additional routes files.


RE: Updating ci with composer problem with shield's route - pippuccio76 - 03-06-2025

(03-05-2025, 05:50 AM)michalsn Wrote: Can't reproduce the problem. Is it working if you move the Shield routes to the main file?

Instead of using "require", you should rather use app/Config/Routing::$routeFiles array for additional routes files.

NO doesn't work if i move to main file too


RE: Updating ci with composer problem with shield's route - michalsn - 03-06-2025

In that case, you missed something during the upgrade. Follow the upgrade instructions again - pay attention to the list of files that have changed.

Preferably, go back to the previous version of CodeIgniter and use the https://github.com/tattersoftware/codeigniter4-patches component to perform the update.


RE: Updating ci with composer problem with shield's route - pippuccio76 - 03-06-2025

(03-06-2025, 10:47 AM)michalsn Wrote: In that case, you missed something during the upgrade. Follow the upgrade instructions again - pay attention to the list of files that have changed.

Preferably, go back to the previous version of CodeIgniter and use the https://github.com/tattersoftware/codeigniter4-patches component to perform the update.

i simply do composer update

but if i go on use CodeIgniter\Router\RouteCollection;

is see declared but not used , why ?

and if i go to $routes i have unset $routes


RE: Updating ci with composer problem with shield's route - michalsn - 03-06-2025

Using the composer update is not enough. You should follow the upgrade instructions dedicated to the version you're upgrading from: https://codeigniter.com/user_guide/installation/upgrading.html


RE: Updating ci with composer problem with shield's route - pippuccio76 - 03-07-2025

(03-06-2025, 11:17 PM)michalsn Wrote: Using the composer update is not enough. You should follow the upgrade instructions dedicated to the version you're upgrading from: https://codeigniter.com/user_guide/installation/upgrading.html

I found error , is on my vendor folder