wearesho-team/yii2-stateless

This package is abandoned and no longer maintained. No replacement package was suggested.

Stateless components factory for Yii2

3.1.0 2018-05-22 14:34 UTC

README

Latest Stable Version Total Downloads Build Status codecov

This package provides single class Wearesho\Yii\Stateless\Factory with:

  • getRedis - returns Redis connection or null, depends on Redis\ConfigInterface
  • getSession - return \yii\web\Session or \yii\redis\Session, if Redis available
  • getCache - returns \yii\caching\FileCache or \yii\redis\Cache, if Redis available
  • getDb - returns \yii\db\Connection depends on Db\ConfigInterface

Note:

Environment variables to make redis available:

Environment variables to instantiate database:

  • DB_HOST - database host or ip
  • DB_NAME - database name
  • DB_USER - database user
  • DB_PORT - port for connection (default 3306 for MySQL, 5432 for PostgreSQL)
  • DB_TYPE - type of database (default pgsql)
  • DB_PASSWORD - database user password (default null)

You can copy .env.example to your project

Installation

composer require wearesho-team/yii-stateless:^3.0

Usage

<?php
// your bootstrap.php file

use Wearesho\Yii\Stateless;

Stateless\Configurator::configure(\Yii::$container);
<?php
// your main.php file
use Wearesho\Yii\Stateless;

$config = [
    // Your Application configuration 
];

return array_merge(Stateless\Configurator::config(\Yii::$container), $config);

For advanced usage

License

MIT