CodeIgniter Forums

Full Version: Services
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

I have GetImageInfo function in my model but i get error:

Class 'App\Models\Config\Services' not found



PHP Code:
$info Config\Services::image()
            ->withFile($file_path)
            ->getFile()
            ->getProperties(true); 


How to use services in model?

I found error... solution is:

PHP Code:
$img = \CodeIgniter\Config\Services::image()
            ->
withFile($file_path)
            ->
getFile()
            ->
getProperties(true); 
I don't recommend using the \CodeIgniter\Config\Services. Just use \Config\Services. It has special features that will life easier down the road as you continue to use it.
@Piotr you were on the right track originally! PHP expects unspecified namespaces within classes to be relative to that class' namespace, hence why it was looking for "App\Models\Config\Services" in your model. As kilishan suggests, specifying the "\" prevents it from being relative and gets you to the right namespace.