Permalink
Browse files

Setup REDIS to store the sessions.

  • Loading branch information...
damienalexandre committed Nov 12, 2015
1 parent e2450db commit 58bc2e149f84d6e9f1083a01fbfee0d2084d9180
Showing with 81 additions and 10 deletions.
  1. +9 −5 README.md
  2. +2 −1 composer.json
  3. +53 −3 composer.lock
  4. +17 −1 src/SantaKernel.php
@@ -12,17 +12,19 @@ srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platfor
- If you haven't already, log in to your Heroku account and follow the prompts to create a new SSH public key.
- Give your heroku details to Damien to be able to deploy
$ heroku login
$ heroku git:remote -a slack-secret-santa
Deploy your application : Commit your code to the repository and deploy it to Heroku using Git.
$ git add .
$ git commit -am "make it better"
$ heroku plugins:install heroku-redis
$ git push heroku master
## Run the project
The app require:
- a Redis server
- PHP 5.6+
As we rely on env variables, we cannot use `server:run`. From `web/`:
SLACK_CLIENT_SECRET=TOTO SLACK_CLIENT_ID=TOTO php -d variables_order=EGPCS -S 127.0.0.1:8000 ../etc/router.php
@@ -31,3 +33,5 @@ Variables are:
- SLACK_CLIENT_SECRET: Application secret from Slack;
- SLACK_CLIENT_ID: Application id from Slack;
- REDIS_URL: The full redis connexion url (default `redis://localhost:6379`)
@@ -20,7 +20,8 @@
"require": {
"bramdevries/oauth2-slack": "^0.1.0",
"cleentfaar/slack": "^0.17.1",
"symfony/symfony": "2.8.x@dev"
"symfony/symfony": "2.8.x@dev",
"predis/predis": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0",

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -2,6 +2,8 @@
namespace Joli\SlackSecretSanta;
use Predis\Client;
use Predis\Session\Handler;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\TwigBundle\TwigBundle;
@@ -79,7 +81,10 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
{
$c->loadFromExtension('framework', [
'secret' => 'NotSoRandom...:)',
'session' => true,
'session' => [
'handler_id' => 'session.handler.predis',
'name' => 'santaSession',
],
]);
$c->loadFromExtension('twig', [
'paths' => [
@@ -92,6 +97,10 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
$_ENV['SLACK_CLIENT_ID'] = 'dummy';
}
if (empty($_ENV['REDIS_URL'])) {
$_ENV['REDIS_URL'] = 'redis://localhost:6379';
}
// Slack application credentials
$c->setParameter('slack.client_secret', $_ENV['SLACK_CLIENT_SECRET']);
$c->setParameter('slack.client_id', $_ENV['SLACK_CLIENT_ID']);
@@ -102,6 +111,13 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
$controller->addArgument(new Reference('twig'));
$controller->addArgument(new Parameter('slack.client_id'));
$controller->addArgument(new Parameter('slack.client_secret'));
$sessionHandler = $c->register('session.handler.predis', Handler::class);
$sessionHandler->setPublic(false);
$sessionHandler->addArgument(new Reference('predis'));
$predis = $c->register('predis', Client::class);
$predis->addArgument($_ENV['REDIS_URL']);
}
/**

0 comments on commit 58bc2e1

Please sign in to comment.