UAMPropelSessionBundle
UAMPropelSessionBundle is an opinitionated symfony bundle that provides a convenient implementation of sessions via Propel ORM., (*1)
The motivation for this bundle was an issue of inconvenience:, (*2)
- Configuring sessions in multiple symfony apps is repetitive, yet so standardized as not worth the effort each time.
- The session table does not really need a schema nor Propel OM classes in the app; yet if not present, the
propel:migration:generate-diff
will attempt to remove it each time it is run.
To resolve this, this bundle provides a ready-to-use configuration for the app's sessions-related settings, as well as a Propel schema for the sessions table., (*3)
This bundle is highly opinionated:, (*4)
It provides no latitude for customization; if the settings it provides are unsuitable for your app, then you should customize the session settings the usual way in your app's configuration., (*5)
This bundle also deliberately ignores basic principles of software design, and assumes the existence of certain named container parameters; if these parameters are absent, the app may fail cryptically. On the other hand, these parameters are usually present in any symfony apps; changing their names in the app config to match the names exeepcted by the bundle presents little difficulty., (*6)
This bundle uses the default table name for sessions (sessions
) and default column names (sess_id
, sess_data
, sess_time
, sess_lifetime
)., (*7)
The following parameters should be defined somewhere in the app:, (*8)
database_host
database_port
database_name
database_user
database_password
Usage
Add the bundle to your app's composer.json
file requirements:, (*9)
require: {
"unitedasian/propel-session-bundle": "~1.0",
...
}
Enable the bundle in your app's kernel:, (*10)
# app/AppKernel.php
public function registerBundles()
{
$bundles = array(
new UAM\Bundle\PropelSessionBundle\UAMPropelSessionBundle(),
...
);
...
return $bundles;
}
Create the sessions
table: There are plenty of ways to do so via a propel command, such as propel:sql:build
; the easiest method is probably to run propel:migration:generate-diff
and then propel:migration:migrate
., (*11)
Update your app's configuration to use the session handler service provided by the bundle:, (*12)
# app/config/config.yml
framework:
session:
handler_id: unitedasian.session.handler.pdo