PHP code example of michalsn / codeigniter-kinde

1. Go to this page and download the library: Download michalsn/codeigniter-kinde library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

michalsn / codeigniter-kinde example snippets




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',
    ];

    // ...

    // ...
    public $files = [
        APPPATH . 'ThirdParty/kinde/src/Common.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);
    }
}