Can't access app\services from console\controller

Hi,

I am trying to access app\services namespace from console\controller namespace. Intelliphense is not marking as incorrect, but when I execute the console, it fails and returns

Exception 'Error' with message 'Class 'app\services\MyService' not found'

This is my folder structure:
backend
–|--services
------|–MyService
common
console
–|--controllers
------|–‘ControllerTryingToAccessMyService’

Any help is appreciated

For some reason, it seems that console does not have access to anything in backend, after moving the services folder to common, it worked. It seems that I’d need to change the configuration. Though I am not sure how to do that.

This have to do with the autoload defined by the PSR standard. You can have more information here: https://www.php-fig.org/psr/psr-4/#2-specification

1 Like