• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Services

#1
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.
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.