Understanding and installing CodeIgniter 4 for modern app development, quick guide

CodeIgniter is the framework of choice to develop applications quickly and in an extensible, flexible and organized way; It is ideal for building small to medium-sized applications and has a fairly low learning curve compared to other modern frameworks like Django or Laravel.

CodeIgniter 4 is many years in the making and is finally available in a stable version; CodeIgniter is chosen by many (including me) for its simplicity and speed when developing our applications.

CodeIgniter, like any php framework, requires LAMP in order to work; ie Apache, MySQL (or other supported databases) and PHP; although it has its own server, so you can do without Apache.

CodeIgniter 4 requires PHP 7.2 to work

What you are going to need would be PHP, which has been our programming language and where this framework is written.

PHP 7 has been with us for a long time and it is normal for 5.x to fade into the background and a modern framework such as CodeIgniter 4 cannot be the exception and unlike version 3, it uses a modern version.

How to install CodeIgniter 4

CodeIgniter maintains the simplicity of its predecessor, and its installation is very simple, whether you want to do it manually or using composer, which has been the most recommended approach since through this mechanism we can easily install third-party dependencies using composer and update the framework with same ease also by composer.

CodeIgniter vs Laravel

And this is one of the aspects that CodeIgniter 4 surpasses Laravel and that is that for the latter, you must install it exclusively through composer and you have to have a set of specific technologies to be able to work, which in the case of Windows, the environment official development goes through installing and developing in this OS goes through a virtualized environment in Ubuntu; if you want to know the comparation of Laravel vs CodeIgniter.

Install CodeIgniter 4 manually

For this option, we have to go to the official site which would be https://codeigniter.com/

And download the framework (you can download it directly as a default option from the official website) that comes in a compressed form, then we unzip it, throw it into our server and buala, we are ready to use it.

Open the app/Config/App.php file and configure your base URL.

If necessary, configure your database in app/Config/Database.php

Install CodeIgniter 4 via composer

This option, as I told you, has been the recommended way since it is the one that allows us to install new packages as well as update CodeIgniter through composer update.

Open a terminal or command prompt and navigate to your web server and run the following command:

composer create-project codeigniter4/appstarter project-root

Parsing the above command

In the previous command we are simply using the composer command to create a project (create-project) and we are indicating which project is going to be created (in CodeIgniter) and finally we indicate the name of the project to be created; that in our case, if we want codeigniter4 to be called:

composer create-project codeigniter4/appstarter codeigniter4

And this would be all.

Recommended environment to develop apps in CodeIgniter 4 if you are using Windows

If you are using Windows, I recommend that you use Laragon; which is the UNofficial ecosystem to develop our applications in Laravel (although you can easily extend it with other technologies as detailed on their website) and it has more than everything we need and more to develop apps in CodeIgniter 4; inclusively, every time we install a new project, when we restart Laragon it automatically generates a virtualhost that we can use to access our project through a clean URL.

For example, in my CodeIgniter 4 course, the project is called simply codeigntier4 and therefore our Laragon detects this project and creates a friendly URL using a ready-made virtualhost so we can use it when developing. If you created your project in CodeIgniter 4 using Laragon, at this point you must restart Laragon so that it generates the clean URL of your project:

http://codeigniter4.test/

Command Line using PHP spark (CLI)

CodeIgniter 4, as a modern framework, brings us a simple command line called spark to create and manage different elements in the project such as:

  • migrations
  • seders
  • Activate the server
  • And many other operations

In general you can use the CodeIgniter command line to generate controllers, models, views and other components of your application. You can also run database migrations, configure the cache, and perform many other important tasks. CodeIgniter's command line is an essential part of this popular PHP-based web development platform.

Conclusions

This has been the fundamental elements to develop in this framework; which goes from creating a project, knowing the necessary environment, talking a little about the CodeIgniter 4 command line.

In subsequent articles we will take the first steps with this framework.

- Andrés Cruz

En español

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 2d 23:35!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

See the books
¡Become an affiliate on Gumroad!