michalsn / codeigniter-kinde
Kinde integration for the CodeIgniter 4 framework
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 3
pkg:composer/michalsn/codeigniter-kinde
Requires
- php: ^8.0
- kinde-oss/kinde-auth-php: ^1.2
Requires (Dev)
- codeigniter4/devkit: ^1.0
- codeigniter4/framework: ^4.3
- rector/rector: 0.17.7
This package is auto-updated.
Last update: 2025-10-06 07:08:39 UTC
README
Basic integration for Kinde authentication.
Installation
Composer
composer require michalsn/codeigniter-kinde
Manually
In the example below we will assume, that files from this project will be located in app/ThirdParty/kinde directory.
Download this project and then enable it by editing the app/Config/Autoload.php file and adding the Michalsn\CodeIgniterKinde namespace to the $psr4 array, like in the below example:
<?php namespace Config; use CodeIgniter\Config\AutoloadConfig; class Autoload extends AutoloadConfig { // ... public $psr4 = [ APP_NAMESPACE => APPPATH, // For custom app namespace 'Config' => APPPATH . 'Config', 'Michalsn\CodeIgniterKinde' => APPPATH . 'ThirdParty/kinde/src', ]; // ...
Also add the required helper to the same file under $files array:
// ... public $files = [ APPPATH . 'ThirdParty/kinde/src/Common.php', ]; // ...
Database
php spark migrate --all
Config
See what configuration variables can be set by looking at the src/Config/Kinde.php file and use the .env file to set them.
See the getting started article for reference.
Routes
loginregisterlogoutcallback
Filers
kinde
Commands
To copy config file to the application namespace.
php spark kinde:publish
Helper functions
authenticated()will check if current user is authenticatedcan('permission')will check if current user has a permissionuser_id()will return current user ID (database)user()oruser('field')will return current user info (database)kinde_user()will return the Kinde user array ornull
Example
<?php namespace App\Controllers; class Home extends BaseController { public function index() { if (! service('kinde')->isAuthenticated()) { return $this->response->setHeader(401)->setBody('401 Unauthorized'); } if (! can('view:home')) { return $this->response->setHeader(401)->setBody('Not enough permissions to view this page'); } return view('home/index', $data); } }