samsonasik / ci4-album
An Example of CodeIgniter 4 Album module
Fund package maintenance!
samsonasik
Installs: 241
Dependents: 0
Suggesters: 0
Security: 0
Stars: 94
Watchers: 8
Forks: 22
Open Issues: 0
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
Requires (Dev)
- codeigniter/coding-standard: ^1.7.15
- codeigniter4/framework: ^4.5.1
- phpstan/phpstan: ^1.10.67
- phpunit/phpunit: ^10.5.20
- rector/rector: dev-main
Conflicts
- codeigniter4/framework: <4.5.1
- dev-master
- 1.15.0
- 1.14.4
- 1.14.3
- 1.14.2
- 1.14.1
- 1.14.0
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-bump-phpstan-2
This package is auto-updated.
Last update: 2024-11-20 21:23:00 UTC
README
Feature
- CRUD with
- Pagination, configurable via
Album\Config\Album
class. - Search
- Layout
- Flash Message after add/edit/delete
Installation
1. Get The Module
a. require via composer
composer require samsonasik/ci4-album
OR
b. manually, by go to app/ThirdParty
directory in project root, and clone this repository to the app/ThirdParty
directory:
cd app/ThirdParty
git clone git@github.com:samsonasik/ci4-album.git
see https://help.github.com/en/github/authenticating-to-github/error-permission-denied-publickey# for common clone issue troubleshooting.
then register "Album" to App/Config/Autoload.php
's psr4 property:
$psr4 = [ 'App' => APPPATH, // To ensure filters, etc still found, APP_NAMESPACE => APPPATH, // For custom namespace 'Config' => APPPATH . 'Config', 'Album' => APPPATH . 'ThirdParty/ci4-album/src', // <-- add this line ];
2. Set CI_ENVIRONMENT, base url, index page, and database config in your .env
file based on your existing database (If you don't have a .env
file, you can copy first from env
file: cp env .env
first). If the database not exists, create database first.
# .env file CI_ENVIRONMENT = development app.baseURL = 'http://localhost:8080' app.indexPage = '' database.default.hostname = localhost database.default.database = ci4_crud database.default.username = root database.default.password = database.default.DBDriver = MySQLi
3. Run db migration
php spark migrate -n Album
4. Run db seed (Optional)
php spark db:seed "Album\Database\Seeds\AlbumSeeder" php spark db:seed "Album\Database\Seeds\TrackSeeder"
5. Run development server:
php spark serve
6. Open in browser http://localhost:8080/album
Settings
Configure pagination per-page, by copy src/Config/Album.php
file into app/Config
directory, and modify the namespace to Config
:
<?php namespace Config; use CodeIgniter\Config\BaseConfig; class Album extends BaseConfig { public $paginationPerPage = 10; } // app/Config/Album.php
In above class, the paginationPerPage
property's value can be changed.
Testing
On very first run, you need to create database, and migration for testing purpose with set phpunit.xml
file from phpunit.xml.dist
:
cd /path/to/modules/ci4-album
cp phpunit.xml.dist phpunit.xml
and then configure the phpunit.xml
to ensure it has a match db configuration with your local dev environment. If the database not exists, create database first.
<php> <server name="app.baseURL" value="http://localhost:8080"/> <const name="HOMEPATH" value="./"/> <const name="CONFIGPATH" value="./vendor/codeigniter4/framework/app/Config/"/> <const name="PUBLICPATH" value="./vendor/codeigniter4/framework/public/"/> <env name="database.tests.hostname" value="localhost"/> <env name="database.tests.database" value="ci4_crud_test"/> <env name="database.tests.username" value="root"/> <env name="database.tests.password" value=""/> <env name="database.tests.DBDriver" value="MySQLi"/> <env name="database.tests.DBPrefix" value=""/> </php>
Ensure that you use different DB for
testing
.
After it, install the codeigniter and phpunit dependency:
cd /path/to/modules/ci4-album && composer install
Lastly, run the test:
vendor/bin/phpunit
Contributing
Contributions are very welcome. Please read CONTRIBUTING.md