Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kenjis/ci3-to-4-upgrade-helper
CodeIgniter 3 to 4 Upgrade Helper
https://github.com/kenjis/ci3-to-4-upgrade-helper
codeigniter codeigniter3 codeigniter4 hacktoberfest upgrade-helper
Last synced: 6 days ago
JSON representation
CodeIgniter 3 to 4 Upgrade Helper
- Host: GitHub
- URL: https://github.com/kenjis/ci3-to-4-upgrade-helper
- Owner: kenjis
- License: mit
- Created: 2021-01-18T10:42:25.000Z (about 4 years ago)
- Default Branch: 1.x
- Last Pushed: 2024-11-06T20:22:35.000Z (3 months ago)
- Last Synced: 2025-01-25T05:05:24.889Z (13 days ago)
- Topics: codeigniter, codeigniter3, codeigniter4, hacktoberfest, upgrade-helper
- Language: PHP
- Homepage:
- Size: 525 KB
- Stars: 67
- Watchers: 7
- Forks: 22
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CodeIgniter 3 to 4 Upgrade Helper
This project helps you upgrade your CodeIgniter3 apps to CodeIgniter4.
- The goal is to reduce upgrade costs.
- It provides compatible interfaces for common use cases in CodeIgniter3 apps.
- It also provides compatible interfaces to test code using [ci-phpunit-test](https://github.com/kenjis/ci-phpunit-test).
- It does not aim to be 100% compatible.
- **This project is under early development.**
- **This project is under early development.**
- We welcome Pull Requests!## Requirements
- CodeIgniter 4.3.1 or later
- [ci4-app-template](https://github.com/kenjis/ci4-app-template) can be used
- PHP 7.4 or later## Sample Code
- https://github.com/kenjis/ci3-to-4-news
- https://github.com/kenjis/ci3-to-4-news/tree/main/tests/app
- https://github.com/kenjis/ci4-online-games-store
- https://github.com/kenjis/ci4-qrcode
- (Japanese) https://github.com/kenjis/ci4-tettei-appsIf you use *ci3-to-4-upgrade-helper*, You can run the following code on CodeIgniter4.
*app/Controllers/News.php*
```php
load->model('news_model');
$this->load->helper('url_helper');
}public function index()
{
$data['news'] = $this->news_model->get_news();
$data['title'] = 'News archive';$this->load->view('templates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');
}public function view($slug = null)
{
$data['news_item'] = $this->news_model->get_news($slug);if (empty($data['news_item'])) {
show_404();
}$data['title'] = $data['news_item']['title'];
$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}public function create()
{
$this->load->helper('form');
$this->load->library('form_validation');$data['title'] = 'Create a news item';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'Text', 'required');if ($this->form_validation->run() === false) {
$this->load->view('templates/header', $data);
$this->load->view('news/create');
$this->load->view('templates/footer');
} else {
$this->news_model->set_news();
$this->load->view('news/success');
}
}
}
```*app/Models/News_model.php*
```php
load->database();
}public function get_news($slug = false)
{
if ($slug === false) {
$query = $this->db->get('news');
return $query->result_array();
}$query = $this->db->get_where('news', ['slug' => $slug]);
return $query->row_array();
}public function set_news()
{
$this->load->helper('url');$slug = url_title($this->input->post('title'), '-', true);
$data = [
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text')
];return $this->db->insert('news', $data);
}
}
```*app/Views/news/create.php*
```phpTitle
Text
```
## How to Upgrade from CI3 to CI4
See [How to Upgrade from CI3 to CI4](docs/HowToUpgradeFromCI3ToCI4.md).
If you have test code with [ci-phpunit-test](https://github.com/kenjis/ci-phpunit-test), see [How to Upgrade Test Code from CI3 to CI4](docs/HowToUpgradeTestCodeFromCI3ToCI4.md).
## For Development
### Installation
composer install
### Available Commands
composer test // Run unit test
composer tests // Test and quality checks
composer cs-fix // Fix the coding style
composer sa // Run static analysys tools
composer run-script --list // List all commands