PHPackages                             wearesho-team/yii2-stateless - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. wearesho-team/yii2-stateless

AbandonedArchivedLibrary

wearesho-team/yii2-stateless
============================

Stateless components factory for Yii2

3.1.0(7y ago)1292[3 PRs](https://github.com/wearesho-team/yii2-stateless/pulls)MITPHPPHP &gt;=7.2.0

Since Apr 2Pushed 7y ago3 watchersCompare

[ Source](https://github.com/wearesho-team/yii2-stateless)[ Packagist](https://packagist.org/packages/wearesho-team/yii2-stateless)[ RSS](/packages/wearesho-team-yii2-stateless/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (21)Used By (0)

Yii2 Stateless
==============

[](#yii2-stateless)

[![Latest Stable Version](https://camo.githubusercontent.com/1004293c19427965d44609123b1107493ece88c87dcced9ac32749913546e012/68747470733a2f2f706f7365722e707567782e6f72672f776561726573686f2d7465616d2f796969322d73746174656c6573732f762f737461626c652e706e67)](https://packagist.org/packages/wearesho-team/yii2-stateless)[![Total Downloads](https://camo.githubusercontent.com/c75049b40ba64b1048ba51482f30e17410d5287d0a1db0725b93e3a3c11fbe6d/68747470733a2f2f706f7365722e707567782e6f72672f776561726573686f2d7465616d2f796969322d73746174656c6573732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/wearesho-team/yii2-stateless)[![Build Status](https://camo.githubusercontent.com/a81cb0c09f3d735ae452e416c17cbc0f124a08324656bde76af3d4cd6044c362/68747470733a2f2f7472617669732d63692e6f72672f776561726573686f2d7465616d2f796969322d73746174656c6573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wearesho-team/yii2-stateless)[![codecov](https://camo.githubusercontent.com/6389d7449d51e349da3af77d843f99b3603d67c490fd53dc1508a6706e780b36/68747470733a2f2f636f6465636f762e696f2f67682f776561726573686f2d7465616d2f796969322d73746174656c6573732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/wearesho-team/yii2-stateless)

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

- `getRedis` - returns Redis connection or null, depends on [Redis\\ConfigInterface](./src/Db/ConfigInterface.php)
- `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](./src/Redis/ConfigInterface.php)

Note:

- [Redis\\ConfigInterface](./src/Redis/ConfigInterface.php) have [Redis\\EnvironmentConfig](./src/Redis/EnvironmentConfig.php) implementation

Environment variables to make redis available:

- **REDIS\_HOSTNAME** - required
- **REDIS\_DATABASE** - required
- **REDIS\_PASSWORD** - default empty
- **REDIS\_PORT** - default 6379
- [Db\\ConfigInterface](./src/Db/ConfigInterface.php) have [Db\\EnvironmentConfig](./src/Db/EnvironmentConfig.php) implementation

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](./.env.example) to your project**

Installation
------------

[](#installation)

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

Usage
-----

[](#usage)

```
