CodeIgniter Forums
Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri - 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: Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri (/showthread.php?tid=90608)

Pages: 1 2


RE: Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri - mywebmanavgat - 05-06-2024

Even if you change the function, you need to edit all your code one by one. Because in the new update, the application folder is also included in the segment.

This has not been this way since ci3. Why did you really do this?


In order not to edit all my code, I applied the following in BaseController.







PHP Code:
public function __construct()
 {

 
$this->uri = new \CodeIgniter\HTTP\URI(str_replace(base_url(),'',current_url()));
 } 



RE: Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri - joeedman - 07-27-2024

Just replace uri to getUri.

PHP Code:
      // $this->language->setLocale($this->session->lang); 
69        // Preload any models, libraries, etc, here.    
70 
71        
// Determine whether to include the template or not
72            $excludedUrls = ['home','/','',NULL'about''login','register','users','/users/register','users/registerUser','registerUser','blog''contact'];
73 
74            
// Get the request URI segment 1
75            $requestUri $this->request->getUri()->getSegments(); // <<<<<<<
76            $this->includeTemplate false;
77            foreach ($requestUri as $urisegment){
78 



RE: Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$uri - eduardofiorini - 12-29-2024

Hello everyone, just replace the old code below:


PHP Code:
$request = \Config\Services::request();
$uri $request->uri

By direct call to the service:


PHP Code:
$uri service('uri'); 

I had the same problem when migrating from version 4.4.3 to the current version 4.5.6