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