How PHP Wax Uses the Model View Controller Pattern
This isn't meant as a complete description of the Model View Controller (MVC) pattern, if it's a new word for you then a bit of research may be in order. However everyone's definition of MVC is a little different so what follows is a basic summary of how PHP Wax uses the pattern to organise an application.
If you have a browse through your newly created application folder you'll see the following structure:
./app ./config ./controller ./db ./lib ./model ./view capfile ./plugins ./public ./images ./javascripts ./stylesheets ./script ./tmp ./log ./cache
By way of a brief introduction to this setup here's a brief summary of an application's components.
The app directory
First up, the app directory contains a few subdirectories. The first of these is the config directory. By default this will contain four files, config.yml, environment.php, production.php, and development.php.
config.yml
You standard configuration file. By default this handles the database setup and other items such as the cache configuration.
environment.php
The environment file is the first file to be included by the framework (inside the index.php file). It sets up 2 constants that are used within the framework:
- WAX_ROOT - The directory the website is running out of.
- FRAMEWORK_DIR - The location of the PHP Wax folder.
It is very rare that you will ever need to change either of those to variables. Once these are set then the WAX_ROOT is added to PHP/acronym>s include path.
The main AutoLoader.php is now loaded.
production.php and development.php
These two files are used for settings that you want to either change or add config settings depending on what environment you are running in.
For example; on your live production server you might want to enable caching on your layout but obviously while you are developing the site you would not want to do that.
Using the Config::set() and Config::get() methods in this file you can do that.
The capfile
This is a capistrano file used for deploying your site.
