0

When I run the PHP development server, I see all request appear twice. It could be an explanation why I am having problems validating CSRF codes (they are generated twice, so the one in the form and the one finally in the session are not the same):

[Fri Mar 20 20:29:53 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51335 Accepted
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51336 Accepted
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51335 [200]: GET /
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51335 Closing
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51336 [200]: GET /
[Fri Mar 20 20:30:07 2020] 127.0.0.1:51336 Closing

Anyone an idea why this is happening?

This is how I started the server:

php -S 0.0.0.0:8080 -t public/

I checked FPM config and changed the value of servers to start to 1 (I thought it might be fpm related), but to no avail.

Mac OS X Catalina (10.15.3), PHP 7.4.1

Extra info:

created a new directory public with 1 index.php file in it containing:

hello world
<?php
file_put_contents(__DIR__ . '/../requests.log', date('Y-m-d H:i:s') . PHP_EOL, FILE_APPEND);

Running the server, and calling the page ONCE:

user@server test % php -S 0.0.0.0:8080 -t public/
[Fri Mar 20 21:04:14 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started
[Fri Mar 20 21:04:16 2020] 127.0.0.1:56020 Accepted
[Fri Mar 20 21:04:16 2020] 127.0.0.1:56021 Accepted
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56020 [200]: GET /
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56020 Closing
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56021 [200]: GET /
[Fri Mar 20 21:04:17 2020] 127.0.0.1:56021 Closing

Yields this in the log:

2020-03-20 20:06:58
2020-03-20 20:06:58

processes on the laptop:

user@laptop test % ps -ef | grep php
    0   163     1   0  8:25PM ??         0:00.13 /usr/local/opt/php/sbin/php-fpm --nodaemonize
  501   331   163   0  8:25PM ??         0:00.00 /usr/local/opt/php/sbin/php-fpm --nodaemonize
  501  1326   163   0  8:37PM ??         0:00.00 /usr/local/opt/php/sbin/php-fpm --nodaemonize

Curl 0.0.0.0:8080 as @maartendev proposed yields:

[Fri Mar 20 21:09:21 2020] PHP 7.4.1 Development Server (http://0.0.0.0:8080) started
[Fri Mar 20 21:09:24 2020] 127.0.0.1:56335 Accepted
[Fri Mar 20 21:09:24 2020] 127.0.0.1:56335 [200]: GET /
[Fri Mar 20 21:09:24 2020] 127.0.0.1:56335 Closing

Thanks Jeroen

Jeroen
  • 982
  • 1
  • 6
  • 14

0 Answers0