How to install Yii PHP framework on Debian 10?

0
80

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 Debian 10.

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 Debian 10

Yii is a flexible PHP framework capable of handling many dependencies for our web application. And there are different ways to install it but the developers of the framework recommend to do it using Composer.

Of course, Yii can be installed on Windows, Linux or macOS.

1) Install Compose on Linux

Composer is a dependency manager for PHP. It helps a lot when an application has a lot of libraries to use. This allows a single command to download them all.

To install Yii, it is recommended to do it with Composer. So, the first step is to install it.

Read How to install Composer on Linux?

Then we can continue with the rest of the tutorial.

2) Installing Yii PHP framework on Debian 10

To install a Yii PHP Framework project just use Composer. So run the following command:

:~$ composer create-project --prefer-dist yiisoft/yii2-app-basic example
1.- Install Yii PHP Framework on Debian 10
1.- Install Yii PHP Framework on Debian 10

Obviously you can replace example with the name of your project.

After everything is installed, we will be able to have our project up and running. But before we work with it, we have to make some changes.

Inside the project folder, create a JSON file with the following content:

:~$ cd example
:~$ 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"
},

What did we just do? Yii uses Composer to handle CSS/Javascript dependencies. If you want NPM to handle it, then you have to do the previous step. If not, skip it.

Finally, we will be able to raise our project with the following command:

:~$ php yii serve
2.- Serve the project
2.- Serve the project

This way the project will be available from http://localhost:8080

And if you want to specify a host and a port, do it in the following way:

:~$ php yii serve 192.168.250.5 --port=1234

Then, open your web browser and you will see the following.

3.- Yii php framework running on Debian 10
3.- Yii php framework running on Debian 10

This means you can start working with Yii now. Create fabulous web applications with this PHP framework.

Conclusion

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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here