Matheus Battisti
Matheus Battisti

Reputation: 31

In a MVC system, where I put my classes that are not part of MVC?

For example: I have a session class, a message class, a CRUD class, in which folder I put them?

my folder structure is:

app/    <-- MVC logic
config/ <-- config files
core/   <-- core files of application, such as init
public/ <-- index and assets
vendor/ <-- for composer packages

Upvotes: 1

Views: 323

Answers (2)

odan
odan

Reputation: 4952

I would recommend the Standard PHP package skeleton as a good root-level directory structure.

config/              # Configuration files
docs/                # Documentation and examples
public/              # Web server files (and front controller)
resources/           # Other resource files (assets, locales, migrations)   
src/                 # PHP source code  (The App namespace)
tests/               # Test code    

Extended version:

vendor/              # Reserved for composer (don't touch this folder)
tmp/                 # Temporary files
tmp/cache/           # Cache files
tmp/logs/            # Log files

MVC directory structure (example):

templates/           # Templates (HTML, Twig files)
src/Controller/      # Controllers and actions, also src/Action
src/Domain/          # Business logic

I think your Session class is a HTTP Session library and the Message class is a validation class (or library). For this reason it should be installed via composer into the vendor/ folder.

It think your "CRUD" class is some kind of a "Data Table Pattern" or DAO or Repository and could be a combination of an external library vendor/ and application specific code src/.

Upvotes: 1

tereško
tereško

Reputation: 58444

What is "core" and "init"? Have you learned about MVC some abomination like CodeIgniter or something?

The "crud classes" (which actually should be data mappers) are part of model layer, same would apply to domain objects, repositories, services and other cod, that is strictly for implementing domain business logic.

The .. emm ... "session class" should probably do in the vendor, since there are dozens of implementations for session abstraction already available. And I have no idea what "message class" is supposed to be, but if you means "request" and "response", then those too should go in the vendor. I would recommend installing Symfony's HttpFoundation standalone component for those features.

Upvotes: 0

Related Questions