In our previous articles, we downloaded and went through the directory structure of the Yii 2 advanced template. Still, we haven't seen anything on the browser except the directory structure at https://localhost/advanced. Initialisation of the template is the process through which Yii generate few files (more specifically, copies from advanced/environment directory to app-specific directory) which are necessary for running the web app, frontend and backend. The files that are generated are index.php, index-test.php, params-local.php, main-local.php, etc.
The Yii 2 advanced template comes with two inbuilt environments - Development and Production. The files specific to these two environments are stored in the environments directory. More on the environment configurations and setup in the later articles.
As you can see from the above snap, when we open the http://localhost/advanced/frontend/web/ in the browser we get to see the directory structure. This is because there is no index.php or index.html file by default in the downloaded template. Take a look at the directory structure below. There is no index.php file present in the backend/web or frontend/web.
The reason there is no index.php files is because Yii want's you to generate these files based on your environment. If you are on production environment then you can initialize the app as Production and if on development, then as Development environment. Let's open the terminal and navigate to the advanced directory using the cd command. Enter ./init and hit enter.
As soon as you hit enter you see some commands running through your console. These commands copy the files form advanced/environments directory to backend and frontend directories. You can thus set up your configurations in these environment files and push it to your repository. While deploying the code you can just initialise the Yii 2 app in the specific environment.
Once the process is completed, navigate to http://localhost/advanced/frontend/web/, you do not see the directory structure, but the above screen. Thus our app is initialised successfully and we are ready to start with our coding.
Also, if you check the files in the advanced directory, you have some new files in the backend/web, backend/config, frontend/web, frontend/config, common/config, console/config directories. The DocumentRoot of our website will be fronted/web and for the admin panel, it will be backend/web.
Now that our app is initialised we will start writing some code to get acquainted with the Yii 2 Framework. Before signing off, I recommend you to go through the output on the command line to get a glimpse of the commands executed and the generated files.