# Organizing Table Classes in Folders

**URL:** <https://discourse.cakephp.org/t/organizing-table-classes-in-folders/3094>\
**Category:** Need Help\
**Created:** [August 25, 2017, 5:30pm UTC](https://discourse.cakephp.org/t/organizing-table-classes-in-folders/3094 "2017-08-25T17:30:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![neojoda](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/neojoda/32/771_2.png) [@neojoda](https://discourse.cakephp.org/u/neojoda)\
**Post date:** [August 25, 2017, 5:30pm UTC](https://discourse.cakephp.org/t/organizing-table-classes-in-folders/3094/1 "2017-08-25T17:30:19Z")

</div>

Hello,

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

> Blockquote  
> namespace App\Model\Table\Stats;  
> use Cake\ORM\Table;  
> class BlockedTable extends Table  
> { …

If I do:

> Blockquote TableRegistry::get(‘Blocked’);

Just getting an instance of

> Blockquote  
> Cake\ORM\Table

I tried to add to the composer.json and then running composer dumpautoload

> Blockquote  
> “App\Model\Table\Stats\”: “src/Model/Table/Stats”,  
> “App\”: “src”,

but still getting the same Cake\ORM\Table class

How should I do it?  
Thanks,  
neojoda

---

<div class="post-metadata">

**Author:** ![neojoda](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/neojoda/32/771_2.png) [@neojoda](https://discourse.cakephp.org/u/neojoda)\
**Post date:** [August 25, 2017, 6:48pm UTC](https://discourse.cakephp.org/t/organizing-table-classes-in-folders/3094/2 "2017-08-25T18:48:09Z")

</div>

OK.  
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

---

<div class="post-metadata">

**Author:** ![raul338](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/raul338/32/69_2.png) [@raul338](https://discourse.cakephp.org/u/raul338)\
**Post date:** [August 29, 2017, 8:10pm UTC](https://discourse.cakephp.org/t/organizing-table-classes-in-folders/3094/3 "2017-08-29T20:10:54Z")

</div>

You can group models/controllers/shells in plugins (using bake).  
So you could create a plugin Supplies and to use it in the rest:

```php
TableRegistry('Supplies.Products');

```

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
