Giter Site home page Giter Site logo

samsonasik / ci4-album Goto Github PK

View Code? Open in Web Editor NEW
94.0 8.0 22.0 372 KB

๐Ÿ”ฅ CodeIgniter 4 example Album module uses Domain Driven Design Architecture with Tactical Pattern

License: MIT License

PHP 100.00%
codeigniter module codeigniter4 reusable database tested album query prg post-redirect-get

ci4-album's Introduction

Example of CodeIgniter 4 Module : Album Module

Latest Version ci build Mutation testing badge Code Coverage PHPStan Downloads

Feature

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 [email protected]: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

ci4-album's People

Contributors

kenjis avatar samsonasik avatar tomasvotruba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ci4-album's Issues

How to implement CQRS in CodeIgniter 4?

Having this reference from DDD how could I implement CQRS in Codeigniter 4, if anyone has any information that could help me I would appreciate it.
It is not an Issue, but that question arises by implementing DDD. Regards !!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.