CI4 - Extending Core System Class - HTTP/URI |
Hello, i upgraded my project from CI3 to CI4. In Upgraded project, i tried to extend the System HTTP\URI class with the reference of CI4 user guide. But extended class not loaded properly.
Code as follows: 1.app/libraries/URI.php Code: <?php namespace App\Libraries; 2.app/config/services.php Code: <?php namespace Config; Note: Extended URI class method($this->setURI) loaded when accessed like Service::uri, else it loads from Codeigniter\HTTP\URI.php if accessed like "new URI()". I want to override the method($this->setURI) completely.
When using new you have to be explicit about the namespace which can be done with use
PHP Code: use App\Libraries\URI; Or it can be done with a fully qualified class name the way you did in app/config/services.php PHP Code: $uri = new \App\Libraries\URI(); Note the leading backslash in the above line of code. |
Welcome Guest, Not a member yet? Register Sign In |