How to install CodeIgniter 4 on Windows and Mac

CodeIgniter 4 requires PHP version 7.2 or higher. The earlier version requires a minimum PHP 5.3 version or higher.

There is now a public directory like in other frameworks. You can now separate the application from the resources (like CSS, JS, files.).

It is much more difficult for attackers.

In this tutorial, I show how you can install the Codeigniter 4 project on Windows and Mac.

How to install CodeIgniter 4 on windows and mac


Contents

  1. Enable extensions
  2. Manual Installation
  3. Using composer
  4. Run
  5. Conclusion

1. Enable extensions

  • Open php.ini file to enable intl and mbstring extension.
  • Search extension in the file.
extension=intl.dll
extension=mbstring.dll

OR

extension=php_intl.dll
extension=php_mbstring.dll
  • Remove semicolon (;) if exists to enable the extension.
  • Restart the server.

2. Manual Installation

  • Download CodeIgniter 4 zip file from here.
  • Copy in the htdocs/ folder and extract it.
  • Rename the folder (e.g. codeigniter4).

How to install CodeIgniter 4 on windows and mac


3. Using composer

  • Navigate to htdocs/ using Command Prompt if you are on Windows and use the terminal if you are on Mac.
  • Run the following command –
composer create-project codeigniter4/appstarter project-root
  • Replace project-root with your project name like – codeigniter4.
  • If you are getting the following message on the Command prompt while running –

How to install CodeIgniter 4 on windows and mac

  • It means intl extension is not been enabled.
  • To enable the extension follow the step 1.
  • Re-run the composer create-project codeigniter4/appstarter project-root.
  • A new codeigniter4 folder will be created.

4. Run

  • Run the project public/ folder.
http://localhost/codeigniter4/public/

How to install CodeIgniter 4 on windows and mac

  • On Mac in case, you are not viewing the above page instead following page display –

How to install CodeIgniter 4 on windows and mac

  • Then need to change the permission of the writable folder.
  • Navigate to the project directory using the terminal and execute the following command and refresh the page.
chmod -R 777 writable

Local Development Server

  • You can also run the project by starting a local development server.
  • Run the following command in the Command Prompt if you are on Windows or on the terminal if you are on Mac.
php spark serve

How to install CodeIgniter 4 on windows and mac

  • Development URL display after starting.
  • Run – http://localhost:8080/ in the browser.

How to install CodeIgniter 4 on windows and mac


5. Conclusion

You can either install it using a composer or manually. Before installing make sure that the PHP version is 7.2 or higher.

If you found this tutorial helpful then don't forget to share.

4 thoughts on “How to install CodeIgniter 4 on Windows and Mac”

Leave a Comment