Converting Shell to Command

How do i import a component from a Command? Before i was able to do the following? I am upgrading from 3.7 → 5.x

$this->dataLogic = new DataLogicComponent(new ComponentRegistry(), );

If you have logic which is needed across controllers and commands its best to extract that logic into a generic PHP Service class and inject it via dependency injection.

https://book.cakephp.org/5/en/development/dependency-injection.html

1 Like