Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.
The template includes three tiers: front end, back end, and console, each of which is a separate Yii application.
The template is designed to work in a team development environment. It supports deploying the application in different environments.
Documentation is at docs/guide/README.md.
Before we start to build our own application, firstly we should have web server and IDE in our local device.
Web Server
There are some excellent all-in-one Windows distributions that contain Apache, PHP, MySQL and other applications in a single installation file, e.g. XAMPP (including a Mac version), WampServer and Web.Developer. In here I used XAMPP as Web Server.
IDE
There are some excellent IDE for PHP such as NetBeans, Notepad++, and Sublime Text 3, but for me NetBeans is the most popular IDE for development. NetBeans editor provides many pre-configured code templates and code generation tools for faster development support, and In her I used NetBeans for IDE.
COMPOSER
Composer is a dependency manager for PHP. It solves the following problems:
- Dependency resolution for PHP packages,
- Autoloading solution for PHP packages,
- Keeping all packages updated.
DOWNLOAD:
After install all tools above, now we install the Yii2 project, there are 2 ways to do it.
Get in to your local web server directory, for example: C:\xampp\htdocs
and then run CMD.
Run this following command
php composer.phar create-project yiisoft/yii2-app-advanced advanced
Download the following archive file, and then extract it to your local web server directory, for example: C:\xampp\htdocs
.
- Yii2 Advanced Template Download as ZIP, Download as TAR.GZ
Yii2 Advanced Template has two environment(Development and Production), each of them has different configuration. So you should initialized your project environment in here.
Run CMD inside your project directory, and run this following command
php init
The following command will create your configuration file
In here I used XAMPP GUI for database, we can access it from http://localhost/phpmyadmin/
.
Then set your database configuration in main-local.php
FILE LOCATION:
- apps
- common
- config
- main-local.php //here is the file
NOTE
some configuration files main.php, params.php, main-local.php, params-local.php. Files main.php and params.php are common for all environments, and files main-local.php and params-local.php are configurations for current environment.
If you should have database for real and test, you should set different configuration for database component in main-local.php and params-local.php.
If you should to enable your configuration to project you should rewrite them in directory /environment. Because all
-local.php
files included into git-ignore section, that's why you can't find-local.php
file in this repository.
Run CMD inside your project directory, and run this following command
php yii migrate
This following command will generate user
and migrate
table inside your database. You can learn more about migrate in here
Run your application in browser and access Sign Up menu, for example url http://localhost/advanced/frontend/web/index.php?r=site%2Fsignup
.
Finally you've installed your application successfully, now you can develop your application using your IDE, you can create needed table through Yii Migrate or manually from SQLEditor.
This framework use MVC(Model, View, and Controller) concept, so you can generate your needed file through Yii2 Generator from the URL http://localhost/advanced/frontend/web/index.php?r=gii
. You should generate in both backend and frontend if you need to use both of them.
You can see my another repository for another magical Yii2 instruction.
Thankyou.
© 2019 - Kevin Pardosi