Welcome Guest, Not a member yet? Register   Sign In
Services
#1

(This post was last modified: 05-12-2019, 02:56 PM by Piotr.)

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); 
Reply
#2

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.
Reply
#3

@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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB