Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kenjis/ci4-news

CodeIgniter 4 News Tutorial
https://github.com/kenjis/ci4-news

codeigniter codeigniter4 php tutorial

Last synced: 3 months ago
JSON representation

CodeIgniter 4 News Tutorial

Awesome Lists containing this project

README

        

# CodeIgniter 4 News Tutorial

See .

If you want to see code to use Auto Routing,
see the [auto-routing](https://github.com/kenjis/ci4-news/tree/auto-routing#codeigniter-4-news-tutorial) branch.

## Folder Structure

```
ci4-news/
├── app/
├── tests/
├── composer.json
├── composer.lock
├── public/
│   ├── .htaccess
│   └── index.php
└── vendor/
└── codeigniter4/
   └── codeigniter4/
```

## Requirements

- PHP 7.4 or later
- `composer` command (See [Composer Installation](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos))
- Git

## How to Use

### Installation

```console
$ git clone https://github.com/kenjis/ci4-news
$ cd ci4-news/
$ composer install
```

### Database Migration and Seeding

Optional, if you use SQLite3 by default.

```console
$ php spark migrate
$ php spark db:seed NewsSeeder
```

### Run PHP built-in Server

```console
$ php spark serve
```

### URLs

| 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 |

#### Routes

```
+--------+--------------+------+---------------------------------+----------------+---------------+
| 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 |
+--------+--------------+------+---------------------------------+----------------+---------------+
```

### Run PHPUnit Tests

```console
$ composer test
```

## Related Projects for CodeIgniter 4.x

### Libraries

- [CodeIgniter 3 to 4 Upgrade Helper](https://github.com/kenjis/ci3-to-4-upgrade-helper)
- [CodeIgniter3-like Captcha](https://github.com/kenjis/ci3-like-captcha)
- [PHPUnit Helper](https://github.com/kenjis/phpunit-helper)
- [CodeIgniter4 Attribute Routes](https://github.com/kenjis/ci4-attribute-routes)
- [CodeIgniter Simple and Secure Twig](https://github.com/kenjis/codeigniter-ss-twig)
- [CodeIgniter4 Viewi Demo](https://github.com/kenjis/ci4-viewi-demo)

### Tutorials

- [CodeIgniter 4 News Tutorial](https://github.com/kenjis/ci4-news)
- [CodeIgniter 4 Validation Tutorial](https://github.com/kenjis/ci4-validation-tutorial)
- [CodeIgniter4 Code Modules Test](https://github.com/kenjis/ci4-modules-test)
- [CodeIgniter 4 File Upload](https://github.com/kenjis/ci4-file-upload)
- [CodeIgniter 4 QueryBuilder Batch Sample](https://github.com/kenjis/ci4-qb-batch-sample)

### Building Development Environment

- [CodeIgniter4 Application Template](https://github.com/kenjis/ci4-app-template)
- [CodeIgniter4 Composer Installer](https://github.com/kenjis/ci4-composer-installer)
- [docker-codeigniter-apache](https://github.com/kenjis/docker-codeigniter-apache)