Welcome Guest, Not a member yet? Register   Sign In
Question about services extending
#1

(This post was last modified: 04-22-2020, 10:41 PM by ScientiFist.)

Hello,

Little stupid question about the services in ci4.

How to make available a service in a whole controller or in many controllers?

For example "service('request')" i have to call it several times in each of my 'public function'.


PHP Code:
<?php namespace App\Controllers;
class 
User extends BaseController
{

public function 
test(){
  
$request service('request');
  echo 
$request->getIPAddress();
 }





I tried to call it in the BaseController but doesn't look like it's working, if anyone can explain it to me ?

Regards,  Heart
Reply
#2

You don't to load it. It's always there as $this->request.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB