CodeIgniter Forums
After GIT Clone: Call to a member function routes() on null - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: After GIT Clone: Call to a member function routes() on null (/showthread.php?tid=93057)



After GIT Clone: Call to a member function routes() on null - elbambolo - 06-25-2025

Good morning,

I have a problem that I can neither solve nor understand:
Let me explain better:

I develop locally, I see the site with php spark serve. everything is perfect.
I do git clone on a remote machine.
I then run composer install and then composer update to install and update all the dependencies.

Of course I go to update app.baseURL with the address of the remote machine, but I get the error:

Call to a member function routes() on null

The first thing that comes to mind is the shield. So I go to check if the shield is installed correctly.

After doing this, I am completely blocked and I don't know what else to check.

CodeIgniter v4.6.1 Command Line Tool - Server Time: 2025-06-25 12:44:13 UTC+02:00

[Error]
Call to a member function routes() on null
at APPPATH/Config/Routes.php:262

Line 262:

Code:
service('auth')->routes($routes, ['except' => ['login', 'register', 'apiCitta']]);
$routes->get('login', '\App\Controllers\UserController::loginView');
$routes->post('login', '\CodeIgniter\Shield\Controllers\LoginController::loginAction');


Composer show:

Code:
bacon/bacon-qr-code                v3.0.1  BaconQrCode is a QR code generator for PHP.
codeigniter4/framework            v4.6.1  The CodeIgniter framework v4
codeigniter4/settings              v2.2.0  Settings library for CodeIgniter 4
codeigniter4/shield                v1.1.0  Authentication and Authorization for CodeIgniter 4
dasprid/enum                      1.0.6  PHP 7.1 enum implementation
endroid/qr-code                    6.0.8  Endroid QR Code
fakerphp/faker                    v1.24.1 Faker is a PHP library that generates fake data for you.
firebase/php-jwt                  v6.11.1 A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
laminas/laminas-escaper            2.17.0  Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs
mikey179/vfsstream                v1.6.12 Virtual file system to mock the real file system in unit tests.
myclabs/deep-copy                  1.13.1  Create deep copies (clones) of your objects
nikic/php-parser                  v5.5.0  A PHP parser written in PHP
paragonie/constant_time_encoding  v3.0.0  Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)
phar-io/manifest                  2.0.4  Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.2.1  Library for handling version information and constraints
phpunit/php-code-coverage          10.1.16 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          4.1.0  FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                4.0.0  Invoke callables with a timeout
phpunit/php-text-template          3.0.1  Simple template engine.
phpunit/php-timer                  6.0.0  Utility class for timing
phpunit/phpunit                    10.5.47 The PHP Unit Testing framework.
psr/clock                          1.0.0  Common interface for reading the clock.
psr/container                      2.0.2  Common Container Interface (PHP FIG PSR-11)
psr/log                            3.0.2  Common interface for logging libraries
sebastian/cli-parser              2.0.1  Library for parsing CLI options
sebastian/code-unit                2.0.0  Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 3.0.0  Looks up which function or method a line of code belongs to
sebastian/comparator              5.0.3  Provides the functionality to compare PHP values for equality
sebastian/complexity              3.2.0  Library for calculating the complexity of PHP code units
sebastian/diff                    5.1.1  Diff implementation
sebastian/environment              6.1.0  Provides functionality to handle HHVM/PHP environments
sebastian/exporter                5.1.2  Provides the functionality to export PHP variables for visualization
sebastian/global-state            6.0.2  Snapshotting of global state
sebastian/lines-of-code            2.0.2  Library for counting the lines of code in PHP source code
sebastian/object-enumerator        5.0.0  Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector        3.0.0  Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        5.0.0  Provides functionality to recursively process PHP variables
sebastian/type                    4.0.0  Collection of value objects that represent the types of the PHP type system
sebastian/version                  4.0.1  Library that helps with managing the version number of Git-hosted PHP projects
setasign/fpdf                      1.8.6  FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.
spomky-labs/otphp                  11.3.0  A PHP library for generating one time passwords according to RFC 4226 (HOTP Algorithm) and the RFC 6238 (TOTP Algorithm) and compatible with Google Authenticator
symfony/deprecation-contracts      v3.6.0  A generic function and convention to trigger deprecation notices
theseer/tokenizer                  1.2.3  A small library for converting tokenized PHP source code into XML and potentially other formats



RE: After GIT Clone: Call to a member function routes() on null - InsiteFX - 06-25-2025

run php spark routes to see if they are there.

check and make sure that shield copied all the config files over to app/Config

app/Config check your uriProtocol sometimes it needs to be changed.


RE: After GIT Clone: Call to a member function routes() on null - paulbalandan - 06-28-2025

service('auth') returns null in your routes that is why you are getting the error. check if you have installed shield correctly. See http://shield.codeigniter.com/getting_started/install/