See https://codeigniter4.github.io/CodeIgniter4/tutorial/index.html.
If you want to see code to use Auto Routing, see the auto-routing branch.
ci4-news/
├── app/
├── tests/
├── composer.json
├── composer.lock
├── public/
│ ├── .htaccess
│ └── index.php
└── vendor/
└── codeigniter4/
└── codeigniter4/
- PHP 7.4 or later
composer
command (See Composer Installation)- Git
$ git clone https://github.com/kenjis/ci4-news
$ cd ci4-news/
$ composer install
Optional, if you use SQLite3 by default.
$ php spark migrate
$ php spark db:seed NewsSeeder
$ php spark serve
Method | URL | Controller | Description |
---|---|---|---|
GET | http://localhost:8080/ | Home::index | the CodeIgniter Welcome page |
GET | http://localhost:8080/pages | Pages::index | the CodeIgniter Welcome page |
GET | http://localhost:8080/home | Pages::view | the “home” page |
GET | http://localhost:8080/about | Pages::view | the “about” page |
GET | http://localhost:8080/shop | Pages::view | a “404 - File Not Found” error page |
GET | http://localhost:8080/news | News::index | the news list page |
GET | http://localhost:8080/news/{slug} | News::show | the news item page |
GET | http://localhost:8080/news/new | News::new | the news create form |
POST | http://localhost:8080/news | News::create | the news creation and the result |
+--------+--------------+------+---------------------------------+----------------+---------------+
| Method | Route | Name | Handler | Before Filters | After Filters |
+--------+--------------+------+---------------------------------+----------------+---------------+
| GET | / | » | \App\Controllers\Home::index | | toolbar |
| GET | news | » | \App\Controllers\News::index | | toolbar |
| GET | news/new | » | \App\Controllers\News::new | | toolbar |
| GET | news/([^/]+) | » | \App\Controllers\News::show/$1 | | toolbar |
| GET | pages | » | \App\Controllers\Pages::index | | toolbar |
| GET | ([^/]+) | » | \App\Controllers\Pages::view/$1 | | toolbar |
| POST | news | » | \App\Controllers\News::create | csrf | toolbar |
+--------+--------------+------+---------------------------------+----------------+---------------+
$ composer test
- CodeIgniter 3 to 4 Upgrade Helper
- CodeIgniter3-like Captcha
- PHPUnit Helper
- CodeIgniter4 Attribute Routes
- CodeIgniter Simple and Secure Twig
- CodeIgniter4 Viewi Demo