My project use Zend 3 framework and php7.2. When I build web on Ubuntu 17.04, this web isn’t working.
> php -S 0.0.0.0:8080 -t public public/index.php
[Thu Dec 7 23:25:59 2017] PHP Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Thu Dec 7 23:25:59 2017] PHP Fatal error: Unknown: Failed opening required '/home/isling/workspace/sp/shopping/public/public/index.php' (include_path='.:/usr/share/php') in Unknown on line 0
'.../public/public/index.php' -> public is duplicated ???
The -t
argument specifies the document root, it is assumed that's where the indicated file is. So you just need this:
php -S 0.0.0.0:8080 -t public index.php
I usually put this in my composer.json
:
"scripts": {
"serve": "php -S 0.0.0.0:8080 -t public/ index.php"
}
Then I can just do composer serve
to get a development server.
[EDIT 2018-04-27] This behavior has changed around version 7.2.3 or so. The filename parameter now appears to be relative to the current directory and not relative to the doc root directory specfied via -t
, so you'd now use something like: php -S 0.0.0.0:8080 -t public/ public/index.php