hamkamannan / adminigniter
Complete Authentication and Authorization system for CodeIgniter4 HMVC with Premium Admin LTE
Installs: 255
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 0
Language:JavaScript
Requires
- php: ^7.3||^8.0
- codeigniter4/framework: ^4.1
- myth/auth: dev-develop
Requires (Dev)
- fakerphp/faker: ^1.13
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^9.1
Suggests
- ext-fileinfo: Improves mime type detection for files
README
Adminigniter
HMVC Module (CRUD) Generator with Complete Authentication and Authorization system for CodeIgniter4 comes with Admin LTE Template.
Feature
- Configurable backend theme Premium Admin LTE
- CSS framework Bootstrap 4
- Icons by Font Awesome 5
- Role-based permissions (RBAC)
- Dynamically-Generated Menu (Drag & Drop)
- Localized English / Indonesian
NOTE: This library was inspired from myth/auth and agungsugiarto/boilerplate
Please feel free to contribute!
Demo On mannan.id
Installation
1. Get The Module
NOTE: Since the myth/auth packages is still under development, we need to change composer.json in root project directory. Open composer.json with your text editor and add code like this, or below like this.
"minimum-stability": "dev", "prefer-stable": true,
And run require via composer
composer require hamkamannan/adminigniter
2. Codeigniter Config
NOTE: Set up your CI_ENVIRONMENT, baseURL, 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 fromenv
file:cp env .env
first). If the database does not exist, create the database first.
#-------------------------------------------------------------------- # ENVIRONMENT #-------------------------------------------------------------------- CI_ENVIRONMENT = development #-------------------------------------------------------------------- # APP #-------------------------------------------------------------------- app.baseURL = 'http://localhost:8888' app.indexPage = '' #-------------------------------------------------------------------- # DATABASE #-------------------------------------------------------------------- # mysql database.default.hostname = 127.0.0.1 database.default.database = adminigniter database.default.username = root database.default.password = root database.default.DBDriver = MySQLi
3. Run publish
, migrate
, seed
NOTE: To publish
Database/Migration
,Database/Seed
,public/assets
,public/themes
,Libraries/DataTables
, and patch HMVCvendor/codeigniter4/framework/system/View/View.php
- Run
php spark adminigniter:publish
php spark adminigniter:publish Publish Database Migration? [y, n]: y created: Database/Migrations/20210101_000000_Auth created: Database/Migrations/20210101_000001_AuthAlterUser created: Database/Migrations/20210101_000002_Adminigniter Publish Database Seed? [y, n]: y created: Database/Seeds/AdminigniterSeeder.php Copy Public Assets? [y, n]: y created: public/assets/* created: public/themes/* Copy Libraries? (Adminigniter Libraries/DataTables) [y, n]: y created: Libraries/DataTables//Utilities/* created: Libraries/DataTables/* Patch View for HMVC? [y, n]: y created: vendor/codeigniter4/framework/system/View/View.php
- Run
php spark migrate
php spark migrate Running: (App) 20210101_000000_App/Database/Migrations/Auth Running: (App) 20210101_000001_App/Database/Migrations/AuthAlterUsers Running: (App) 20210101_000002_App/Database/Migrations/Adminigniter
- Run
php spark db:seed AdminigniterSeeder
php spark db:seed AdminigniterSeeder Seeded: App/Database/Seeds/AdminigniterSeeder
4. Configuration (Auth, Filter, and Autoload)
NOTE: Everything about how to configure auth you can find add myth/auth
- app/Config/Auth.php
Open
app/Config/Auth.php
find$views, $passwordValidators and etc
and changes with these lines below:
public $defaultUserGroup = 'user'; public $views = [ 'login' => 'hamkamannan\adminigniter\Views\auth\login', 'register' => 'hamkamannan\adminigniter\Views\auth\register', 'forgot' => 'hamkamannan\adminigniter\Views\auth\forgot', 'reset' => 'hamkamannan\adminigniter\Views\auth\reset', 'emailForgot' => 'hamkamannan\adminigniter\Views\auth\emails\forgot', 'emailActivation' => 'hamkamannan\adminigniter\Views\auth\emails\activation', ]; public $allowRegistration = true; public $requireActivation = false; public $activeResetter = false; public $allowRemembering = true; public $passwordValidators = [ 'Myth\Auth\Authentication\Passwords\CompositionValidator', 'Myth\Auth\Authentication\Passwords\NothingPersonalValidator', 'Myth\Auth\Authentication\Passwords\DictionaryValidator', 'Myth\Auth\Authentication\Passwords\PwnedValidator', ];
- app/Config/Filters.php
Open
app/Config/Filters.php
, find$aliases
and add these lines below:
public $aliases = [ 'csrf' => CSRF::class, 'toolbar' => DebugToolbar::class, 'honeypot' => Honeypot::class, 'login' => \Myth\Auth\Filters\LoginFilter::class, 'role' => \hamkamannan\adminigniter\Filters\RoleFilter::class, 'permission' => \hamkamannan\adminigniter\Filters\PermissionFilter::class, ];
- app/Config/Autoload.php
Open
app/Config/Autoload.php
, find$psr4
and add these lines below:
public $psr4 = [ APP_NAMESPACE => APPPATH, // For custom app namespace 'App' => APPPATH, 'Config' => APPPATH . 'Config', 'DataTables' => APPPATH . 'Libraries/DataTables', 'Adminigniter' => APPPATH . 'Adminigniter', ];
5. Run Module Generator
NOTE: This provide command to create new module and clone available module (Dashboard, Report, Banner, Page).
- Run
php spark module:create
Dummy
php spark module:create Dummy created: Adminigniter/Database/Migrations/2021-05-16-050256_Dummy.php created: Adminigniter/Modules/Backend/Dummy/Config/Routes.php created: Adminigniter/Modules/Backend/Dummy/Controllers/Dummy.php created: Adminigniter/Modules/Backend/Dummy/Controllers/Api/Dummy.php created: Adminigniter/Modules/Backend/Dummy/Models/DummyModel.php created: Adminigniter/Modules/Backend/Dummy/Views/list.php created: Adminigniter/Modules/Backend/Dummy/Views/add.php created: Adminigniter/Modules/Backend/Dummy/Views/update.php
- Run
php spark module:clone
Page
php spark module:clone Page created: Adminigniter/Modules/Backend/Page/Config created: Adminigniter/Modules/Backend/Page/Models created: Adminigniter/Modules/Backend/Page/Controllers created: Adminigniter/Modules/Backend/Page/Views created: Adminigniter/Modules/Backend/Page created: Module Page has been clone created: Adminigniter/Database/Migrations/2021-05-16-102329_Page.php
- Run
php spark migrate -n Adminigniter
php spark migrate -n Adminigniter Running: (Adminigniter) 2021-05-16-050256_App/Adminigniter/Database/Migrations/Dummy Running: (Adminigniter) 2021-05-16-102329_App/Adminigniter/Database/Migrations/Page
6. Run development server:
NOTE: Running on port
8888
php spark serve --port 8888
7. Open in browser http://localhost:8888/dummy
Default user and password +----+--------+-------------+ | No | User | Password | +----+--------+-------------+ | 1 | admin | password | +----+--------+-------------+
Usage
You can find how it works with the read code routes, controller and views etc.
Contributing
Contributions are very welcome.
License
This package is free software distributed under the terms of the MIT license.