This is an old revision of the document!
Table of Contents
CodeIgniter 4
Simple demo of CI4 framework.
Environment
Devuan Chimaera 4.0
Install Apache & PHP
apt update apt full-upgrade apt install apache2 php php-cli php-mbstring php-intl php-curl
Install CI4
Download package and unzip into htdocs.
mkdir -p /var/www/htdocs cd /var/www/htdocs wget https://api.github.com/repos/codeigniter4/CodeIgniter4/zipball/v4.1.9 -O ci4.zip unzip ci4.zip mv codeigniter4-CodeIgniter4-202f41a hostname.kewl.org cd hostname.kewl.org chown www-data:www-data writable
Configure apache
<VirtualHost *:80> DocumentRoot "/var/www/htdocs/hostname.kewl.org/public" ServerName hostname.kewl.org ServerAdmin root Header append X-FRAME-OPTIONS "SAMEORIGIN" RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* /index.php/$1 [L] <Directory "/var/www/htdocs/hostname.kewl.org/public"> Options None AllowOverride None </Directory> CustomLog /var/log/apache2/hostname.kewl.org/access.log combined ErrorLog /var/log/apache2/hostname.kewl.org/error.log </VirtualHost>
Configure CI4
Change baseURL and indexPage in app config.
vi app/Config/App.php
Change logging threshold if required.
vi app/config/Logger.php
Hello world
Create controller.
vi app/Controllers/Hello.php
<?php namespace App\Controllers; class Hello extends BaseController { public function index() { echo view('Hello'); } } ?>
Create view
vi app/Views/Hello.php
<!DOCTYPE html> <html lang="en"> <head> <title>Hello World</title> </head> <body> <p>Hello World</p> </body> </html>
Visit URL
http://hostname.kewl.org/Hello