Which approach is best to get a table instance in cakephp 3.0

I am new to Cakephp and started with cake3.

The question arises as to which approach is best suited for performance in order to get a table instance in CakePHP-3.0, which is not the default controller between loadModel or TableRegistry.

For example:

1. $this->loadModel('Articles'); OR 2. TableRegistry::get('Articles'); 

I read Cake-Doc for loadModel and TableRegistry . This is where the confusion begins.

Thanks in advance

+7
source share
1 answer

If it is better to use loadModel() in the controller. The reason is that unit testing is easier to fake.

It also sets the variable $this->[MyTable] according to the loaded table.

+8
source share

All Articles