PHP code example of kirillemko / yii-ci-integration

1. Go to this page and download the library: Download kirillemko/yii-ci-integration 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/ */

    

kirillemko / yii-ci-integration example snippets




onConfig = [
    'id' => 'yii_sub_app',
    'basePath' => dirname(__DIR__),
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=' . $db['default']['hostname'] . ';dbname=' . $db['default']['database'] . '',
            'username' => $db['default']['username'],
            'password' => $db['default']['password'],
            'charset' => 'utf8',
        ],
    ],

];

$webOnlyConfig = [
    'components' => [
        'request' => [
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
            ]
        ],
    ]
];

$consoleOnlyConfig = [
    'bootstrap' => ['gii'],
    'modules' => [
        'gii' => [
            'class' => 'yii\gii\Module',
        ],
    ],
];

if (defined('APP_CONSOLE')) {
    return array_merge_recursive($commonConfig, $consoleOnlyConfig);
}

return array_merge_recursive($commonConfig, $webOnlyConfig);


class Users extends ActiveRecord implements ExternalIdentityInterface
{

    public function getId() {
        return $this->id;
    }

    public static function getIdentity() {
        $ci = &get_instance();
        $user_id = $ci->ion_auth->get_user_id();
        if( !$user_id ){
            return null;
        }
        return static::findOne($user_id);
    }
}


$yiiConfig = Application($yiiConfig); // Do NOT call run() here