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

Contents

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

1. Enable extensions

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

OR

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


2. Manual Installation

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


3. Using composer

  • Navigate to htdocs/ using Command Prompt when on Windows and using terminal when on Mac.
  • Run the following command -
composer create-project codeigniter4/appstarter project-root

  • Replace the project root with your project name as codeigniter4.
  • Running the following command -
composer create-project codeigniter4/appstarter codeigniter4

  • While running the above command if you get any error that means intl extension is not been enabled.
  • To enable the extension follow step 1.
  • Restart 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/

  • On Mac, if you are not able to see the webpage then we need to change the permission of writable folder.
  • Navigate to the project directory using the terminal and execute the following command and restart the page.
chmod -R 777 writable

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

  • Display of development URL after startup.
  • Run - http://localhost:8080/ browser.


5. Conclusion

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