Application
It depends on you, how you want to structure your application.
It's a good practise to put your stuff inside a src
or app
folder.
MVC is just a helper method providing a more or less clean folder structure for it.
You should read about PSR and namespaces, to understand how to name your classes.
If you follow PSR standards, you get a direct relation of folder names, file names and namespaced class names inside these files.
/src
- /controller
- ModuleAController.php
- ModuleBController.php
- /model
- /helper
- /view
- bootstrap.php
- config.php
- index.php
or
/src
- /core
- corefiles.php
- ...
- /modules
-/aModule
- /controller
- /model
- /helper
- /view
- bootstrap.php
- config.php
- index.php
Composer
Composer is a package manager. You can fetch packages with it. These packages are stored into the vendor
folder. Packages are defined inside the composer.json
file of your project. You might define two seperate require sections: require
, which defines the dependencies for your project, and require-dev
, which defines the dependencies only needed for the development of your project.
Composer acts also as an autoload generator, for your whole project (your app and all it's dependencies).
{
"autoload": {
"psr-4": {"YourApplicationNamespace\\": "src/"}
}
}
You simply have to require composers autoload file from the vendors folder in the bootstrap of your project.
require 'vendor/autoload.php';
If the components are standalone and reusable, you might create them as seperate composer packages and require them in your main application. This would for instance work for a "logger" package. Some of framework projects compose their main project this way.
Composer Custom Installer
If components are coupled to a common base layer (CMS or Framework), you might utilize a custom composer installer, so that packages get installed into the correct folder.
You find a lot of folder layouts and structure information here: http://github.com/composer/installers
project
-vendor
-(packages installed via composer)
-public_html (assets and main index.php)
-src
- core
- helpers
(composer packages for this application, installed into specific folders)
- themes
- sunshine (theme package installed into themes folder)
- modules
- guestbook (module package installed into modules folder)