25 C
Texas
angeloma
Senior Writer and partner

How to install Yii PHP framework on Ubuntu 20.04?

Web programming has a very important place nowadays. And within the web technologies, the PHP language is one of the most popular. That’s why several frameworks bring together the development process. Today, I’ll show you how to install Yii PHP framework on Ubuntu 20.04

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.

Yii is not so different from frameworks like Laravel or CakePHP but it provides another way of doing things. Let’s say similar but not the same.

- Advertisement -

How to install Laravel on Ubuntu 20.04?

How to install CakePHP on Ubuntu 20.04?

So, let us start.

Install Yii PHP Framework on Ubuntu 20.04

As it is a PHP framework, it is required that you have PHP installed on your computer. It also installs some PHP modules, as well as the unzip package.

:~$ sudo apt install php php-pdo php-intl php-xml php-zip php-mbstring phpunit php-mysql php-sqlite3 unzip

1.- Install Composer on Ubuntu 20.04

The installation method recommended by the Yii development team is to use composite.

As we have explained, Composer is a PHP dependency manager that can be installed on Linux, very easily.

How to install PHP Composer on Ubuntu 20.04?

Also, you can get more information about Composer with this post:

Using Composer on Linux

When Composer is installed and well configured, we can start the installation.

2.- Installing Yii PHP framework on Ubuntu 20.04

With Composer already installed, you can start the installation of Yii with the following command:

:~$ composer create-project --prefer-dist yiisoft/yii2-app-basic project

You have to replace project with the name of your desired project.

Then the installation will start and when it is finished, you will see this screen.

1.- Install Yii PHP framework on Ubuntu 20.04
1.- Install Yii PHP framework on Ubuntu 20.04

Optionally you can make npm handle Javascript dependencies and not Composer. If you want to do it, edit the file composer.json

And in the end, 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"
},

So, save the changes and close the file.

The next step is to serve the project, to prove that all is well. If you did the installation on a local computer, execute this command:

:~$ php yii serve
Server started on http://localhost:8080/
Document root is "/home/angelo/project/web"
Quit the server with CTRL-C or COMMAND-C.
[Mon May 18 22:39:44 2020] PHP 7.4.3 Development Server (http://localhost:8080) started
2.- Serve projects on Yii
2.- Serve projects on Yii

And this will make the project available from http://localhost:8080

You can also specify a host and a port:

:~$ php yii serve 192.168.250.20 --port=1234
3.- Serve the project on a different host and port
3.- Serve the project on a different host and port

Finally, open your favorite web browser and go to http://host:port and you will see the following:

4.- Yii PHP framework on Ubuntu 20.04
4.- Yii PHP framework on Ubuntu 20.04

So, Yii is ready to start developing web applications.

Conclusion

Yii is a less popular framework than CakePHP 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.

So, share this post, join our Telegram Channel and buy us a coffee 🙂

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article