24.9 C
Senior Writer and partner

How to install Yii framework on CentOS 8?

We know that web development occupies a lot of place in today’s world. In fact, more and more business applications are made with web technology. You can use NodeJS or a programming language like PHP. PHP is perhaps the most popular language for web development although there are other technologies that are increasing in popularity at a constant rate like NodeJS. But there is no doubt that PHP is very popular. To make quality applications in PHP you have to use a framework and there are many of those, but today we will teach you how to install Yii PHP framework on CentOS 8.

In order to be pragmatic and flexible, Yii PHP was born. It is a framework for object-oriented PHP development that uses the architectural pattern MVC. What makes it ideal for developing many web applications such as forums, information sites or virtual shopping.

With Yii PHP you will have no licensing problems because it is open source (BSD Licence) which makes it ideal for community, educational or long-range projects.

Install Yii PHP Framework on CentOS 8

From the project’s website, we recommend using composer to perform the installation. This is because the framework has many dependencies and Composer is the best for it.

- Advertisement -

So the first step is to install Composer on CentOS 8

Install Composer on CentOS 8

Installing Composer on CentOS 8 is quite simple, but you have to install some previous packages.

So, open a terminal session and run the following:

:~$ sudo dnf install php php-json php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip curl

What have we just installed? Well, first of all, PHP so you can interpret Composer. Then, we installed a series of extensions that will also work for Yii. Finally, curl is a utility that we will use to download Composer.

Then, we proceed to download and install it.

:~$ curl -sS https://getcomposer.org/installer | php

Next, we will make Composer available from the terminal with the following commands:

:~$ sudo mv composer.phar /usr/local/bin/composer 
:~$ sudo chmod +x /usr/local/bin/composer 
:~$ source ~/.bashrc 

Now, you can check if everything went well with the next command:

:~$ composer -v 

If it shows you the version or helps you, it’s all right.

Getting Yii framework on CentOS 8

Once Composer is properly installed, we can install the Yii framework.

To do so, just use the following command:

:~$ composer create-project --prefer-dist yiisoft/yii2-app-basic example
1.- Installing Yii framework on CentOS 8
1.- Installing Yii framework on CentOS 8

This command will download and configure the entire directory structure of Yii making it available to us. In this case, the project is called “example“, but obviously you can change this.

Remember that when you run this command, it will create a folder with the name of the project in the current location.

By default, Yii allows Composer to handle CSS/Javascript dependencies. If you want Composer not to do it and you want NPM, you have to do the following steps.

:~$ cd [your-project]
:~$ nano composer.json

And add the following:

"replace": {
    "bower-asset/jquery": ">=1.11.0",
    "bower-asset/inputmask": ">=3.2.0",
    "bower-asset/punycode": ">=1.3.0",
    "bower-asset/yii2-pjax": ">=2.0.0"

As I said, it’s not mandatory.

To check that everything is in order, we will serve the project.

From the project location, run the following command:

:~$ php yii serve
2.- Serve the Yii application
2.- Serve the Yii application

This will allow the project to be displayed in a web browser at http:/localhost:8080. Remember that this port has to be available in the firewall.

However, we can specify a different host and port:

:~$ php yii serve [Ip-address] --port=[port]

Then open your browser and go to your project and you will see the following:

3.- Yii framework on CentOS 8
3.- Yii framework on CentOS 8

So, that is it. You are ready to start creating fantastic web applications with Yii framework.


Yii is a less popular framework than Cake or Laravel, but equally powerful. Many websites are made with this framework and the results are fantastic for the developer and the end-user.

On the other hand, the installation of Yii is facilitated thanks to its compatibility with Composer.

Please share this post and join our Telegram Channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article