tonydspaniard / yiinitializr-advanced

Yii Framework project structure boilerplate for advanced application requirements
67 stars 30 forks source link

YIInitializr-advanced

The following is a proposed project structure for advanced applications that works in conjunction with YIInitializr components.

YIInitializr vanilla projects make extensive use of Composer. We found at 2amigos.us that is easier to your extensions bundle outside of your application scope - thanks to Phundament and Tobias Munk for his knowledge and shares. Composer is your dependency package best friend.

The package is cleaned from extensions, you choose what you wish to include in your composer.json files. The only ones included are Yii Framework (obviously), YiiStrap and YiiWheels, the rest is up to you. We do not want to confuse you.

Setup and first run

Important

When you first run install and after the deployment script installs the dependencies, creates your runtime and assets folders, it will ask you for your environment. Make sure you use "dev" for your local development settings and "stage" or "prod" for their respective environment types. Also, is important that the files are actually there, do not say "master" without "master.php" not being actually there.

For more information about using Composer please see its documentation.

How to configure the application

This boilerplate is very similar to YiiBoilerplate but differs from it for the easiness of its configuration. We focused to release the pain of configuring your application and combine your configuration files. Yiinitializr\Helpers\Initializr is very easy to use, check for example the bootstrap index.php file at the frontend:

require('./../../common/lib/vendor/autoload.php');
require('./../../common/lib/vendor/yiisoft/yii/framework/yii.php');

Yii::setPathOfAlias('Yiinitializr', './../../common/lib/Yiinitializr');

use Yiinitializr\Helpers\Initializer;

Initializer::create('./../', 'frontend', array(
    __DIR__ .'/../../common/config/main.php', // files to merge with
    __DIR__ .'/../../common/config/env.php',
    __DIR__ .'/../../common/config/local.php',
))->run();

For more information about Yiinitializr please check it at its github repo.

Overall Structure

Bellow the directory structure used:

   |-api
   |---config
   |-----env
   |---controllers
   |---extensions
   |-----components
   |-----filters
   |---models
   |---www
   |-backend
   |---components
   |---config
   |-----env
   |---controllers
   |---extensions
   |---helpers
   |---lib
   |---models
   |---modules
   |---tests
   |---views
   |-----layouts
   |-----site
   |---widgets
   |---www
   |-----css
   |-------fonts
   |-----img
   |-----js
   |-------libs
   |-common
   |---components
   |---config
   |-----env
   |---extensions
   |-----components
   |---helpers
   |---lib
   |-----YiiRestTools
   |-------Common
   |---------Enum
   |---------Exception
   |-------Helpers
   |-----Yiinitializr
   |-------Cli
   |-------Composer
   |-------Helpers
   |-------config
   |---messages
   |---models
   |---schema
   |---widgets
   |-console
   |---commands
   |---components
   |---config
   |-----env
   |---data
   |---extensions
   |---migrations
   |---models
   |-frontend
   |---components
   |---config
   |-----env
   |---controllers
   |---extensions
   |---helpers
   |---lib
   |---models
   |---modules
   |---tests
   |---views
   |-----layouts
   |-----site
   |---widgets
   |---www
   |-----assets
   |-----css
   |-------fonts
   |-----img
   |-----js
   |-------libs

Extensions

The following extensions are part of YIInitializr-basic template:

2amigOS!
web development has never been so fun
www.2amigos.us