Download the PHP package m1/stash-silex without Composer
On this page you can find all versions of the php package m1/stash-silex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download m1/stash-silex
More information about m1/stash-silex
Files in m1/stash-silex
Package stash-silex
Short Description StashSilex is a Silex service provider and session handler for the popular caching library Stash
License MIT
Homepage https://github.com/M1/StashSilex
Informations about the package stash-silex
StashSilex
StashSilex is a Silex service provider and session handler for the popular caching library Stash.
Requirements
StashSilex requires PHP version 5.3+
, Silex version 1.*
and Stash version 0.11+
Install
Via Composer
Usage
You use the StashServiceProvider to register the service provider with the usual syntax for registering service providers:
There's a few options you can use when registering the service provider.
Pools
You can register either one pool using pool.options
or multiple using pools.options
, this works like the
Doctrine Service Provider.
Registering one pool:
Registering multiple pools:
You can access your pools through $app['pool']
and $app['pools']['the_key_of_your_pool']
. If you have multiple pools, then your
first pool registered will be available through $app['pool']
.
For example, in the above code, the FileSystem
pool will be available through $app['pool']
and $app['pools']['fs']
.
Drivers
The driver option is based on the class names for the available drivers, see here for the class names defined by Stash. The driver names are case sensitive.
You can set the driver options through options
like so:
You can see the full list of the available options for each driver here.
The default driver if no driver is defined is the Ephemeral
driver.
Logger
You can also set the logger for the pool via the logger
option like so:
The logger is monolog
due to the MonologServiceProvider
populating $app['monolog']
. The logger option is a string
which your logger service can be accessed through $app
.
For example if you decided to not use Monolog
through the service provider (not recommended), you can use your custom logger like so:
Sessions
You can choose to handle your sessions through Stash in a couple of different ways.
The first way is via the service provider.
The below creates sessions with defaults:
You can also set the ttl
and the session prefix
(what namespace it is stored in in stash, more info here) like so:
You can also set the SessionHandler
manually via:
Recommendations
Instead of setting the options through an array, think about using a config loader like m1/vars
,
where you can just load the configuration of your pool(s) via a file like so:
This way makes it so much easier to make small little changes without having to dive into code.
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Miles Croxford
- All Contributors
License
The MIT License (MIT). Please see License File for more information.