{"action":"created","issue":{"url":"https://api.github.com/repos/cloudfoundry/php-buildpack/issues/96","repository_url":"https://api.github.com/repos/cloudfoundry/php-buildpack","labels_url":"https://api.github.com/repos/cloudfoundry/php-buildpack/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/cloudfoundry/php-buildpack/issues/96/comments","events_url":"https://api.github.com/repos/cloudfoundry/php-buildpack/issues/96/events","html_url":"https://github.com/cloudfoundry/php-buildpack/pull/96","id":101226290,"number":96,"title":"Detect and configure a persistent session store","user":{"login":"dmikusa-pivotal","id":4643262,"avatar_url":"https://avatars.githubusercontent.com/u/4643262?v=3","gravatar_id":"","url":"https://api.github.com/users/dmikusa-pivotal","html_url":"https://github.com/dmikusa-pivotal","followers_url":"https://api.github.com/users/dmikusa-pivotal/followers","following_url":"https://api.github.com/users/dmikusa-pivotal/following{/other_user}","gists_url":"https://api.github.com/users/dmikusa-pivotal/gists{/gist_id}","starred_url":"https://api.github.com/users/dmikusa-pivotal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmikusa-pivotal/subscriptions","organizations_url":"https://api.github.com/users/dmikusa-pivotal/orgs","repos_url":"https://api.github.com/users/dmikusa-pivotal/repos","events_url":"https://api.github.com/users/dmikusa-pivotal/events{/privacy}","received_events_url":"https://api.github.com/users/dmikusa-pivotal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-08-16T02:34:22Z","updated_at":"2016-03-29T12:42:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cloudfoundry/php-buildpack/pulls/96","html_url":"https://github.com/cloudfoundry/php-buildpack/pull/96","diff_url":"https://github.com/cloudfoundry/php-buildpack/pull/96.diff","patch_url":"https://github.com/cloudfoundry/php-buildpack/pull/96.patch"},"body":"This PR adds code so the build pack will look at bound services and detect if a capable session store (currently redis or memcached) has been bound.  If one is found, it configures PHP to use the service for session storage instead of the default which is the local file system.\r\n\r\nPR Includes:\r\n\r\n  - new build pack extension with session functionality\r\n  - docs for usage\r\n  - set of unit tests to confirm basic functionality\r\n\r\nAdditional testing can be done with a simple script such as this one.\r\n\r\n```\r\n<?php\r\n    if (! session_start()) {\r\n        print 'Session Start Failed :(<br/>\\n';\r\n    }\r\n?>\r\n<html>\r\n<head>\r\n    <title>Session Test</title>\r\n</head>\r\n<body>\r\n    <h1>Current Session Id: <?php print session_id(); ?></h1>\r\n    <h1>Current Node: <?php print $_SERVER[\"SERVER_ADDR\"]; ?></h1>\r\n    <h3>Session Dump</h3>\r\n    <pre><?php print_r($_SESSION); ?></pre>\r\n    <h3>Session Counter Test</h3>\r\n    <p>This app increments a counter.  When multiple instances of the app are deployed, the counter should still increase properly.</p>\r\n    <?php\r\n        if (! array_key_exists('counter', $_SESSION)) {\r\n            $_SESSION['counter'] = 0;\r\n        } else {\r\n            $_SESSION['counter'] += 1;\r\n        }\r\n    ?>\r\n    <h3>Counter: <?php print $_SESSION['counter']; ?></h3>\r\n</body>\r\n</html>\r\n``` \r\n\r\nWhen enabled the output should be a counter that increments and the `Current Node` should rotate."},"comment":{"url":"https://api.github.com/repos/cloudfoundry/php-buildpack/issues/comments/202875816","html_url":"https://github.com/cloudfoundry/php-buildpack/pull/96#issuecomment-202875816","issue_url":"https://api.github.com/repos/cloudfoundry/php-buildpack/issues/96","id":202875816,"user":{"login":"dmikusa-pivotal","id":4643262,"avatar_url":"https://avatars.githubusercontent.com/u/4643262?v=3","gravatar_id":"","url":"https://api.github.com/users/dmikusa-pivotal","html_url":"https://github.com/dmikusa-pivotal","followers_url":"https://api.github.com/users/dmikusa-pivotal/followers","following_url":"https://api.github.com/users/dmikusa-pivotal/following{/other_user}","gists_url":"https://api.github.com/users/dmikusa-pivotal/gists{/gist_id}","starred_url":"https://api.github.com/users/dmikusa-pivotal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmikusa-pivotal/subscriptions","organizations_url":"https://api.github.com/users/dmikusa-pivotal/orgs","repos_url":"https://api.github.com/users/dmikusa-pivotal/repos","events_url":"https://api.github.com/users/dmikusa-pivotal/events{/privacy}","received_events_url":"https://api.github.com/users/dmikusa-pivotal/received_events","type":"User","site_admin":false},"created_at":"2016-03-29T12:42:26Z","updated_at":"2016-03-29T12:42:26Z","body":">Is it a common use case for developers to persist session information to redis or memcachd in PHP apps? \r\n\r\nI'm not really sure.  The use case would be for scaling up applications that use sessions, but using sticky sessions is not sufficient or appropriate.  For example, if you have an application where the loss of the session could represent the loss of a substantial amount of work.\r\n\r\n>If it's something you feel would be directly useful for a good number of php-buildpack users we'll make a story to merge in the PR (it looks like tests are failing right now because we've made some commits to develop since the PR was submitted).\r\n\r\nThere were two main reasons I did this.  A coworker asked me if it was possible and I had to tell him not at the moment and because the Java Build Pack does support it.  It's probably a more advanced feature, but I do think that it would be genuinely useful to users.\r\n\r\nDan"}}