Installing and serving CodeIgniter 4 on Windows, Linux or MacOs

- Andrés Cruz

En español
Installing and serving CodeIgniter 4 on Windows, Linux or MacOs

CodeIgniter 4 is a modern framework for PHP that is characterized by being easy to use, a better learning curve than other frameworks such as Laravel, few requirements, easy to configure and install and therefore, it is a great framework that we can learn to take the first steps with PHP.

Codeigniter is an agile framework used for the development of web applications; al seru n framework, it provides a lot of features and functionality for developers following modern schemes and patterns; It is a scalable framework thanks to which composer uses, we can easily install new dependencies and keep the project up to date.

In short, CodeIgniter 4 is ideal for small and medium projects, let's see how to install it.

We are going to learn how we can install CodeIgniter 4, for this we have two different ways; one completely manual and another via composer; these are the only two ways we have to work with C4.

Install CodeIgniter 4 manually

To install CodeIgniter 4 manually, we simply have to download the framework from the main website and unzip it:

You give the name to the folder that you want to have for your project and copy it to your server, which in my case I am in a windows environment and using Laragon with CodeIgniter 4:

Descargar e instalar C4

You copy it to your server and that's it, that's it, it's basically the same installation as its predecessor, version 3 of CodeIgniter:

CodeIgniter 4 y Laragon

Install CodeIgniter 4 by composer

To install C4 via composer we can use the following command that remembers that you can check it in the official documentation in case it changes or is updated at some point:

composer create-project codeigniter4/appstarter project-root

Where project-root is the name of the project.

The best way to install CodeIgniter 4: manual goes composer

As of today, the most recommended way to work with CodeIgniter 4 would be via composer, and the reason is that this way you can easily update the framework and install dependencies i.e. other packages easily via composer.

Recommended environment to develop your projects in Codeigniter 4

In this section we are going to explain how we can install C4 on our computer, depending on the OS you are using.

On Windows

If you are using Windows, I recommend that you use Laragon, which is the environment we use when we develop applications in Laravel; but you can also use your Wampp or any variant like Xampp. Carry out the installation of composer on your part and that's it.

Another difference is that you would have to create your virtual host if you are NOT using Laragon to work with C4 in case you want to access your project via a clean URL.

On Mac or Linux

If you are using Mac or Linux, you cannot use Laragon, since this software is only available for Windows Operating Systems; yes, you would have to perform the manual installation of your LAMPP as we explained in:

Run or serve your project in CodeIgniter 4

Finally, to access the project in C4, you can do it perfectly from localhost:

Or if you use a virtualhost, for example:

<VirtualHost *:80>    DocumentRoot "C:/laragon/www/democodeig4/public/"    ServerName democodeig4.test    ServerAlias *.democodeig4.test    <Directory "C:/laragon/www/democodeig4/public/">        AllowOverride All        Require all granted    </Directory> </VirtualHost>

Or you can also use spark's serve command:

php spark serve

And if you go to your browser, in any of the above cases you will see something like the following:

Ejecutar C4 en el navegador

And this would be all, and with this we have our project ready to start developing our applications in this simple but powerful framework.

Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.