I have a lot of Table Classes in my project.
I would like to organize the classes files by folder (Users, Stats, etc)
I have one class under src/Model/Table/Stats/BlockedTable.php
class BlockedTable extends Table
If I do:
Just getting an instance of
I tried to add to the composer.json and then running composer dumpautoload
but still getting the same Cake\ORM\Table class
How should I do it?
If I do:
TableRegistry::get('Blocked', ['className' => 'App\Model\Table\Stats\BlockedTable']);
Then it works.
Is there a way to configure CakePHP so I do not have to specify the className every time?
PD: Using className there is no need to modifiy the composer.json
You can group models/controllers/shells in plugins (using bake).
So you could create a plugin Supplies and to use it in the rest:
But! I don’t know (I didn’t try yet) is how to link from the plugin to the base App.
Lets say you got the table Contractors and is used in several tables/plugins, if you keep ContractorsTable in the main App in the plugin you can’t call “belongsTo”, so you should make a BasePlugins for the core models. Just my opinion