Add a component from a subfolder

Hello,

is there a way to load components from a subfolder?
I have a cakephp 4 application and load my components on the fly with the command:

$this->loadComponent( 'Order' );

However, when I enter a path, I get an error.
$this->loadComponent( 'order/Order' );

Can anyone help me?

This is not supported (yet). In the meantime you can try to use Service Classes as action arguments via Dependency Injeciton to easily share logic inside and between controllers.

Since Service Classes are just plain PHP Classes you can create as many folders as you like due to the namespace functionality.

Otherwise if you desire to have subfolder functionality inside components can you please create an issue in our cakephp/cakephp repository?

Thanks @KevinPfeifer :slight_smile: