Component store in subfolder


#1

Hi how can i do this,

$this->Components->load('api/UserComponent');

calling a component from folder structure like so:

app/Controller/Component/api/UserComponent.php

#2

just leaving ‘Component’ from name should be enough

$this->loadComponent('api/User');

alternatively:

i havent tried it but you can probably use className for this

use app/Controller/Component/api/UserComponent;

...

$this->loadComponent('User', [
     'className' => UserComponent::class
]);

#3

I got it working now my stupid mistake forgot to add Component sufix the filename call

I followed cakephp 3 className

$this->loadComponent(‘User’, [ ‘className’ => UserComponent::class ]);

thanks for reply anyway