Codeigniter
Appstarter Project Version: Codeigniter v4.1 Requirements: php extensions
php --ini #check php.ini in use
sudo gedit /etc/php/7.4/apache2/php.ini
sudo gedit /etc/php/8.0/apache2/php.ini
extension=curl
extension=intl
extension=mbstring
sudo service apache2 restart
Create new appstarter project
Update composer dependencies and set writable folder permisions.
cd /var/www/tests.local/php/codeigniter/
composer create-project codeigniter4/appstarter myproject
cd myproject/
composer update --ignore-platform-reqs
sudo chown -R $USER.www-data writable
http://tests.local/php/codeigniter/myproject/public/
# Welcome page Codeigniter
Routes
Add new route for Pages. Add controller and view template. For debugging you need to enable development environment.
// app/Config/Routes.php
...
$routes->get('/', 'Home::index');
$routes->get('(:any)', 'Pages::view/$1');
// app/Controllers/Page.php
namespace App\Controllers;
class Page extends BaseController
{
public function index()
{
return view('welcome_message');
}
public function view($id)
{
$data = array();
$data['id'] = $id;
return view('page/view', $data);
}
}
// app/Views/page/show.php
<h1>Page <?= esc($id) ?></h1>
// Copy env file -> .env
CI_ENVIRONMENT = development
It works!
http://tests.local/php/codeigniter/myproject/public/page/3
# Page 3
Last update: 450 days ago