Commit f781d911 authored by Fabien Potencier's avatar Fabien Potencier

merged branch davedevelopment/symfony-session-refactoring (PR #284)

Commits
-------

537b8088 Updated docs to reflect session refactoring
d1bd57d1 Updated to reflect symfony refactoring - needs doc updates

Discussion
----------

Updated Session Provider to reflect symfony refactoring - needs doc updates

I'm not really sure what's required here, but here's what I had to do to get my app working again…

---------------------------------------------------------------------------

by Koin at 2012-03-19T14:12:57Z

omg, thanks davedevelopment.
I'm not the only one to have this problem.

---------------------------------------------------------------------------

by spantaleev at 2012-03-19T20:53:02Z

Good. I just saw this myself and was about to fix it, but you're already ahead.
Can we get the necessary doc updates and have this merged in?

---------------------------------------------------------------------------

by dguyon at 2012-03-20T09:06:32Z

@davedevelopment do you have time to add some docs that reflects your changes ?

---------------------------------------------------------------------------

by igorw at 2012-03-20T09:18:11Z

Looks good to me, please update the docs.

---------------------------------------------------------------------------

by davedevelopment at 2012-03-20T09:26:17Z

Will get the docs updated today
On Mar 20, 2012 9:18 AM, "Igor Wiedler" <
reply@reply.github.com>
wrote:

> Looks good to me, please update the docs.
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/fabpot/Silex/pull/284#issuecomment-4591304
>

---------------------------------------------------------------------------

by davedevelopment at 2012-03-20T13:29:09Z

I did a quick test of the above with rst2html and it seem to render ok. The docs at api.symfony.com don't seem to have been updated yet (tried the master branch), so I left out hyperlinks for now.

---------------------------------------------------------------------------

by igorw at 2012-03-20T13:47:20Z

👍

---------------------------------------------------------------------------

by dguyon at 2012-03-20T13:49:38Z

Thanks for this quick patch !
parents 8835a38d 537b8088
......@@ -9,19 +9,19 @@
{
"package": "symfony/browser-kit",
"version": "dev-master",
"source-reference": "afa16de6b91833b5a72ca89dc942ffb424737687",
"source-reference": "15c0a5f96283399eabcd71a957522c3e39d646ef",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/class-loader",
"version": "dev-master",
"source-reference": "8bceaa2f1fed52f6285b2cea39e7ae37fbea1c9b",
"source-reference": "da83c40b126ce8622fc052332b2c54a135ed976c",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/css-selector",
"version": "dev-master",
"source-reference": "dcce8174c551814c7aadcf13a2f8d73f3a6b4347",
"source-reference": "5fadf85067442c6aa0e76e407eca3a2b60e910c5",
"alias": "2.1.9999999.9999999-dev"
},
{
......@@ -33,37 +33,37 @@
{
"package": "symfony/event-dispatcher",
"version": "dev-master",
"source-reference": "f6b7f60b0c29ab8167de7d7c9ba78fc9cc283c64",
"source-reference": "502614d7dcd2260d0adaef19a344cbd42aa29adf",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/finder",
"version": "dev-master",
"source-reference": "b3adc8d5c29593db93c0abc4711a1e25fd3a6fa0",
"source-reference": "be30ecc95281d729ee51b9e89644d442bcf60451",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/http-foundation",
"version": "dev-master",
"source-reference": "2abe7f1b8e0f808dad0cc001b9d69371b604d719",
"source-reference": "14e1db6ae4035200704ec580596951f7d3b7a29d",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/http-kernel",
"version": "dev-master",
"source-reference": "cf2bb8655a13fcb516b1d0b95ddf0c51db25b2a8",
"source-reference": "18bbb1d116fecb5b4c6c110322eab56577a731c5",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/process",
"version": "dev-master",
"source-reference": "6aceac404d8574cf7da57e7e29b00a665b7bd559",
"source-reference": "0aad81ae9f884cf7df6387cb52a11b5b4f07b3d6",
"alias": "2.1.9999999.9999999-dev"
},
{
"package": "symfony/routing",
"version": "dev-master",
"source-reference": "d3d9c02357b2db6503539d11f6c379ccd86f9cc4",
"source-reference": "db09d0ee5032ab1320966ba7610c576ce7fb1368",
"alias": "2.1.9999999.9999999-dev"
}
],
......
......@@ -7,10 +7,9 @@ medium to large websites use a database to store sessions instead of files,
because databases are easier to use and scale in a multi-webserver
environment.
Symfony2 has multiple session storage solutions and one of them uses PDO to
store sessions, `PdoSessionStorage
<http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Storage/PdoSessionStorage.html>
To use it, replace the ``session.storage`` service in your application like
Symfony2's ``NativeSessionStorage`` has multiple storage handlers and one of them uses PDO to
store sessions, ``PdoSessionHandler``.
To use it, replace the ``session.storage.handler`` service in your application like
explained below.
Example
......@@ -18,7 +17,7 @@ Example
::
use Symfony\Component\HttpFoundation\Session\Storage\PdoSessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
$app->register(new Silex\Provider\SessionServiceProvider());
......@@ -41,8 +40,8 @@ Example
);
});
$app['session.storage'] = $app->share(function () use ($app) {
return new PdoSessionStorage(
$app['session.storage.handler'] = $app->share(function () use ($app) {
return new PdoSessionHandler(
$app['pdo'],
$app['pdo.db_options'],
$app['session.storage.options']
......
......@@ -8,13 +8,13 @@ Parameters
----------
* **session.storage.save_path** (optional): The path for the
``NativeFileSessionStorage``, defaults to the value of
``NativeFileSessionHandler``, defaults to the value of
``sys_get_temp_dir()``.
* **session.storage.options**: An array of options that is passed to the
constructor of the ``session.storage`` service.
In case of the default ``NativeFileSessionStorage``, the possible options are:
In case of the default ``NativeSessionStorage``, the possible options are:
* **name**: The cookie name (_SESS by default)
* **id**: The session id (null by default)
......@@ -34,8 +34,10 @@ Services
<http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Session.html>`_.
* **session.storage**: A service that is used for persistence of the
session data. Defaults to a `NativeFileSessionStorage
<http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Storage/NativeFileSessionStorage.html>`_.
session data. Defaults to a ``NativeSessionStorage``
* **session.storage.handler**: A service that is used by the ``session.storage``
for data access. Defaults to a ``NativeFileSessionHandler`` storage handler.
Registering
-----------
......
......@@ -14,7 +14,8 @@ namespace Silex\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\Session\Storage\NativeFileSessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -35,10 +36,16 @@ class SessionServiceProvider implements ServiceProviderInterface
return new Session($app['session.storage']);
});
$app['session.storage.handler'] = $app->share(function () use ($app) {
return new NativeFileSessionHandler(
isset($app['session.storage.save_path']) ? $app['session.storage.save_path'] : null
);
});
$app['session.storage'] = $app->share(function () use ($app) {
return new NativeFileSessionStorage(
isset($app['session.storage.save_path']) ? $app['session.storage.save_path'] : null,
$app['session.storage.options']
return new NativeSessionStorage(
$app['session.storage.options'],
$app['session.storage.handler']
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment