Install CodeIgniter 3.1 for PHP 8.x: a maintenance guide
Set up an existing CodeIgniter 3 project on PHP 8.x with a maintained fork, basic configuration and deployment checks.
CodeIgniter 3 remains useful for existing applications, but the original 3.1.13 release predates recent PHP versions. On PHP 8.2 and later, legacy code or libraries can trigger deprecations and type errors. Plan a test migration rather than applying arbitrary replacements in framework files.
Requirements
Use a PHP version supported by the fork you choose, a web server such as Apache or Nginx, and any database and PHP extensions required by your application. For MySQL, enable mysqli. Check the web and CLI PHP versions and loaded modules separately; they may differ.
php -v
php -m
Get the source
For a fresh historical 3.1.13 copy, download its tagged archive. For a maintained application on current PHP, inspect the pocketarc CodeIgniter 3 fork and its releases before using it. The fork aims to preserve CI3 behavior while maintaining compatibility with newer PHP versions. Check its release notes, license and changes, then test your own code.
wget https://github.com/bcit-ci/CodeIgniter/archive/refs/tags/3.1.13.zip
unzip 3.1.13.zip
mv CodeIgniter-3.1.13 my-project
cd my-project
Configure the application
Set base_url in application/config/config.php and database credentials in application/config/database.php. Keep secrets outside the repository. Use an environment-specific configuration for production and confirm the database account has only the privileges it needs.
$config['base_url'] = 'https://example.com/';$db['default'] = array(
'hostname' => 'localhost',
'username' => 'db_user',
'password' => 'YOUR_SECRET',
'database' => 'db_name',
'dbdriver' => 'mysqli'
);
PHP 8 compatibility
Warnings about null values or countable types require investigation at the actual call site. Blindly replacing strlen($str) with strlen((string)$str), or count($data) with count((array)$data), can change behavior and hide bugs. Prefer a tested maintained fork and patch your own application code and third-party libraries deliberately.
File permissions
Only application/cache and application/logs need to be writable when those features are used. Give the web server account access to those directories; avoid making the entire application tree writable by the web server or using recursive permissive modes.
sudo chown -R www-data:www-data application/cache application/logs
sudo chmod -R u+rwX,g+rX application/cache application/logs
Nginx example
If the project is served from its root, deny direct access to application and system, hidden files and arbitrary PHP scripts. Route requests to index.php and adapt the PHP-FPM socket to the installed version. Add HTTPS, server-specific hardening and logs before production.
server {
listen 80;
server_name example.com;
root /var/www/my-project;
index index.php;
location / { try_files $uri $uri/ /index.php?$query_string; }
location ~ ^/(application|system)/ { deny all; }
location ~ /\. { deny all; }
location ~ \.php$ { return 404; }
location = /index.php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
Verify and deploy
Open the site and exercise routes, database operations and logs under the target PHP version. Set development mode only during local testing; use production mode and disable displayed errors on the public site. Back up application and database before replacing framework files.
define('ENVIRONMENT', 'production');
Further reading
The maintained fork is at https://github.com/pocketarc/codeigniter and the original 3.1.13 installation guide at https://codeigniter.com/userguide3/installation/index.html. For a new application, consider CodeIgniter 4.
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0