This repository has been archived by the owner on Aug 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an example with Docker to show websupport-sk/pecl-memcache#23
- Loading branch information
0 parents
commit 29d5b3e
Showing
9 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# pecl-memcache Issue #23 | ||
|
||
This repository reproduces the issue described in | ||
[websupport-sk/pecl-memcache#23][pecl-memcache-23]. | ||
|
||
In short, on PHP 7.1, when using `memcache` as the `session.save_handler`, the | ||
following warning occurs when calling `session_start()`: | ||
|
||
``` | ||
Warning: session_start(): Failed to read session data: memcache (path: tcp://127.0.0.1:11211) | ||
``` | ||
|
||
The same code and settings does not result in this warning on PHP 7.0. | ||
|
||
|
||
## Running the Example | ||
|
||
This example uses [Docker][] and [Docker Compose][] to build two images and run | ||
two containers (one for PHP 7.0 and one for PHP 7.1). Both are identical, expect | ||
for the version of PHP used. | ||
|
||
``` bash | ||
git clone /~https://github.com/ramsey/pecl-memcache-issue-23 | ||
cd pecl-memcache-issue-23/ | ||
docker-compose up | ||
``` | ||
|
||
Now, the two containers should be running, you can open the following in your | ||
browser to verify: | ||
|
||
* <http://localhost:8001/info.php> (should be running PHP 7.0) | ||
* <http://localhost:8002/info.php> (should be running PHP 7.1) | ||
|
||
To test the `session_start()` issue and see the warning, open the following: | ||
|
||
* PHP 7.0: <http://localhost:8001/> (the session should work as expected) | ||
* PHP 7.1: <http://localhost:8002/> (`session_start()` should generate a warning) | ||
|
||
|
||
[pecl-memcache-23]: /~https://github.com/websupport-sk/pecl-memcache/issues/23 | ||
[docker]: https://docs.docker.com/ | ||
[docker compose]: https://docs.docker.com/compose/overview/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: '3' | ||
services: | ||
php70: | ||
build: | ||
context: ./docker | ||
dockerfile: Dockerfile | ||
args: | ||
php_version: "7.0" | ||
image: pecl-memcache-issue-23:php70 | ||
ports: | ||
- "8001:8000" | ||
volumes: | ||
- .:/code | ||
php71: | ||
build: | ||
context: ./docker | ||
dockerfile: Dockerfile | ||
args: | ||
php_version: "7.1" | ||
image: pecl-memcache-issue-23:php71 | ||
ports: | ||
- "8002:8000" | ||
volumes: | ||
- .:/code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ARG php_version=latest | ||
FROM php:${php_version} | ||
|
||
COPY docker-setup.sh docker-entrypoint /usr/local/bin/ | ||
COPY memcache.ini /usr/local/etc/php/conf.d/ | ||
|
||
RUN /usr/local/bin/docker-setup.sh \ | ||
&& rm /usr/local/bin/docker-setup.sh | ||
|
||
WORKDIR /code | ||
EXPOSE 8000 | ||
|
||
ENTRYPOINT ["docker-entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -e | ||
/usr/bin/memcached -m 50 -p 11211 -u memcached -l 127.0.0.1 -d | ||
php -S 0.0.0.0:8000 -t /code/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
apt-get -y update | ||
apt-get -y install memcached zlib1g-dev | ||
|
||
groupadd -r memcached && useradd -r -g memcached memcached | ||
|
||
mkdir -p /code/pecl-memcache | ||
cd /code | ||
|
||
curl -L -o pecl-memcache.tar.gz /~https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.tar.gz | ||
tar --strip-components=1 -C /code/pecl-memcache/ -zxf pecl-memcache.tar.gz | ||
|
||
cd /code/pecl-memcache | ||
phpize | ||
./configure | ||
make | ||
make install | ||
|
||
cd /code | ||
rm -rf /code/pecl-memcache/ pecl-memcache.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extension = memcache.so | ||
session.save_handler = memcache | ||
session.save_path = "tcp://127.0.0.1:11211" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
session_start(); | ||
|
||
$_SESSION['foo'] = 'bar'; | ||
|
||
?> | ||
|
||
<h1>Hello!</h1> | ||
|
||
<p>I just stored some data to the session.</p> | ||
|
||
<p><a href="next.php">Go to the next page to read data from the session.</a></p> | ||
|
||
<ul> | ||
<li><code>PHP version: <?php echo phpversion(); ?></code></li> | ||
<li><code>pecl/memcache version: <?php echo phpversion('memcache'); ?></code></li> | ||
<li><code>session.save_handler = <?php echo ini_get('session.save_handler'); ?></code></li> | ||
<li><code>session.save_path = <?php echo ini_get('session.save_path'); ?></code></li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
phpinfo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
session_start(); | ||
|
||
header('Content-Type: text/plain'); | ||
|
||
echo '$_SESSION = ' . "\n\n"; | ||
|
||
var_export($_SESSION); |