How to Install YII on MacOS ?


YII is an open source, object oriented, component-based MVC web framework written in PHP. Its alpha version was released in October, 2006. Its first formal version 1.0 was released in December, 2008. The current version of YII is 2.0.0 which also supports PHP 7. it can be an acronym for Yes It Is. In this tutorial, we will install YII2 on MacOS.


  1. MacOS
  2. Login as an administrator on terminal
  3. PHP 5.4.X or higher
  4. PCRE Extension
  5. Reflection Extension
  6. SPL Extension
  7. CType Extension
  8. MBString Extension
  9. OpenSSL Extension
  10. Intl Extension


The installation process includes following steps.

1) Using Composer to install YII

YII can simply be installed with composer. The following command can be used to create a YII application inside /Library/WebServer/Documents.

  1. $ composer create-project -prefer-distyiisoft/yii2-app-basic MyAPP  

How to Install YII on MacOS

This will create an application named as MyApp inside directory /Library/WebServer/Documents.

2) Provide Hidden tokens:

During the installation Process, the shell prompts us to provide hidden token which needs to be generated from our GitHub repository.

How to Install YII on MacOS

For this purpose, we need to login to our GitHub account and follow the following sequence in order to generate tokens.

  1. Goto user profile ---> select settings ---> Developer Settings ---> Personal access tokens ---> generate new tokens   

It will open the page appears like following.

How to Install YII on MacOS

Click on Generate token to generate the new personal access tokens.

How to Install YII on MacOS

How to Install YII on MacOS

Copy the generated tokens and paste into the terminal. Since the tokens are hidden so they will not be shown so press Enter after pasting.

How to Install YII on MacOS

It will install the YII application MyAPP successfully on the desired location.

3) Start the server

First, we need to change our working directory to the newly created application by typing following command on terminal.

  1. $ cd MyAPP  

Then execute the following command to run the YII server which will by default listen to the port 8080.

  1. $ php yii serve   

How to Install YII on MacOS

4) Access on browser

Just type localhost:8080to access YII on browser through localhost.

How to Install YII on MacOS

Hence, we have successfully installed YII and created our first YII powered application MyAPP on MacOS.

Contact Us logo Whatsapp