Codeigniter is a very powerful php framework, but it is quite light, simple, and easy to learn. Codeigniter itself uses the MVC pattern, namely Model, View, Controller where you can separate the logic and appearance of the website that you will build with this MVC framework.
However, before you install and use Codeigniter. According to the official codeigniter site documentation, CI4 requires PHP specifications >= 7.2. If you are still using PHP version < 7.2, it is recommended to update first.
And also there are some requirements needed when installing Codeigniter 4, namely:
- intl extension
- mbstring extension.
- php-json
- php-mysqlnd
- php-xml
For those of you Windows users, you can directly open the file
php.ini
on XAMPP then uncomment for the above extension (will also be discussed in the middle of the tutorial).
Download Codeigniter4 from the Official Website
- First, please visit the official Codeigniter website Here and please download it. As shown in the image below. Previously make sure the PHP version on your PC or laptop is 7.2 or above. If not, please update first.
- Please wait a few moments until the download is complete.
- When you're done, you'll get a .zip file. Please extract it first.
- If you have extracted it, please rename the file name to ci4 or according to your wishes.
- Then, please move the folder into htdocs. As in the image below. Here I use XAMPP, if you don't use XAMPP please adjust it.
- Done.
Install Through Composer
1. First, please open CMD or Command Prompt on your PC or laptop.
2. Then, please type the command as below
composer create-project codeigniter4/appstarter project-root//thencd project-root//thencomposer update
3. If it is finished, please try running it. There are two options to run it.
- The first option, please open a browser on your PC or laptop. Then type
localhost/ci4
- Then, please click Public. And if your codeigniter is successful the results will look like the image below.
- Then the second option is for you to open a terminal and type:
php spark serve
- Don't forget you have to be in the codeigniter folder beforehand.
- Then, please open the browser and type
localhost:8080
- And if successful, it will look like the image below.
- 4. Done.
Overcome Errors When Installing Composer
When downloading Codeigniter 4 directly on the official website or through composer, and running it with php spark serve sometimes an ext-intl error appears as shown below.
Then, how to solve it?
1. How to solve ext-intl error in Windows:
- First, please open XAMPP-Control. Then, please click Config in the Apache section.
- Then, please click PHP (php.ini).
- Then, please Uncomment on the extension
extension=intl
- . Please remove the "semicolon" in front of it. As in the image below.
- Then, please restart the webserver you are using.
2. How to solve ext-intl error on Linux:
- Please open a terminal. Then, please type
sudo apt install php-intl
- And restart the web server that you are using.
3. How to solve ext-intl errors on Mac:
- For mac you can use
brew
- Please type
brew install php70-intl
- Then, adjust to the php version you have, please check the php version you are using with
php -v
- Then type brew install php71-intl for php 7.1
- Then, brew install php72-intl for php 7.2
- Then, brew install php73-intl for php 7.3
- And, brew install php74-intl for php 7.4
So this article discusses how to install Codeigniter on a PC or laptop. Hopefully this article can be useful and help you. Thank you..!!!