Install CodeIgniter 4 with Composer: requirements and setup
Current PHP requirements, App Starter, project folders, .env and public document root for a new CodeIgniter 4 project.
For a new CodeIgniter 4 project, first check the framework release and its supported PHP runtime. Current documentation requires PHP 8.2 or newer for recent releases. An existing CodeIgniter 4.6 project on PHP 8.1 needs a planned, tested migration rather than a blind framework update. Composer and App Starter are the usual way to start a new application.
Check PHP, extensions and Composer
Run the commands for both the CLI PHP used by Composer and the web server PHP. intl and mbstring are required; json is part of modern PHP. Enable the relevant MySQL driver, curl or gd/imagick only when your application needs them. Composer must satisfy the chosen package requirements. The older PHP 8.1 compatibility of earlier releases is not a blanket requirement for a fresh current install.
php -v
php -m
composer --version
Choose an installation method
App Starter uses Composer to manage the framework under vendor and supplies the project skeleton. A manual download of an official release is possible without Composer, but upgrades require reviewing the changelog and project files. Never modify system; keep application changes in app and follow the upgrade guide.
Create an App Starter project
From the parent directory, create the skeleton and start the built-in server only for development. Composer resolves a compatible release according to the package constraints and your PHP version; verify what it installed. The development server is not a production web server.
composer create-project codeigniter4/appstarter project-root
cd project-root
php spark serve
Understand the folders
app contains your code; public is the only web document root; writable holds logs and cache; tests contains tests; vendor holds dependencies and the framework core. Pointing the web server at the project root risks exposing configuration and source. With a manual install, system resides in the project rather than vendor.
Configure .env
Copy env to .env, then set app.baseURL, the environment and database credentials only if a database is used. Check the actual keys in your installed release. Keep .env outside version control and public. For production, use CI_ENVIRONMENT=production, an appropriate URL and write access only where needed.
cp env .env
Configure the web server
Set Apache DocumentRoot or Nginx root to project-root/public. php spark serve is for local development, not the production deployment. Check HTTPS, application URL, writable permissions and that .env, app and vendor are inaccessible over HTTP.
Deploy and upgrade
Commit or deploy composer.lock, then run composer install --no-dev on the server to install locked versions without development dependencies. Use composer update in development when deliberately changing dependencies, read the upgrade guide, test the result, and deploy the lockfile and required app/public changes. install and update serve different purposes.
composer install --no-dev --prefer-dist --no-interaction
Official references
Requirements: https://codeigniter4.github.io/CodeIgniter4/intro/requirements.html ; Composer: https://codeigniter4.github.io/CodeIgniter4/installation/installing_composer.html ; manual installation: https://codeigniter4.github.io/CodeIgniter4/installation/installing_manual.html .
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0