Welcome Guest, Not a member yet? Register   Sign In
Service not working - showing undefined function service()
#1

I am tying to use service in Common.php like my other projects. But do not know why this is showing me the following error.

Quote:Fatal error: Uncaught Error: Call to undefined function service() in C:\Users\...\app\Common.php:19


Codes from Config/Services.php

PHP Code:
<?php namespace Config;

use 
CodeIgniter\Config\Services as CoreServices;

require_once 
SYSTEMPATH 'Config/Services.php';

class 
Services extends CoreServices
{
 public static function 
testService$getShared FALSE )
 {
 if(!
$getShared) return new \App\Models\TestModel;
 return static::
getSharedInstance('testService');
 }



Codes from App/Common.php

PHP Code:
<?php

if(!function_exists('test')){
    function test(){
        return service('testService')->test();    // Line number 19
    }
}

echo 
test(); 

Could you please help me to solve this issue? Thanks in advance.
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply


Messages In This Thread
Service not working - showing undefined function service() - by webdevron - 05-04-2020, 01:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB