0

So I'm watching Laracasts videos and got confused on how he got the document to listen to a folder on his desktop?

enter image description here

in the picture attached is a screenshot of his document root folder listening on php-learning folder on the Desktop similar to mine. I'm using OS X EL Capitan. My document root says /Users/myname

I'm using the terminal to call php -S localhost:8888

3 Answers 3

1

I figured it out, when you're working with a PHP server through command line make sure in terminal you change directory CD into the folder and start the server within the terminal php -S localhost:whateveryoupick.

Sign up to request clarification or add additional context in comments.

Comments

1

for everyone else like me who looking for fast answer here is command to start PHP server with specified folder listing

php -S localhost:2376 -t /var/www/tmp

for windows user path are different it will be like c:\www\tmp If you need to run this server continually add it to your system startup path , in linux run

$ crontab -e
@reboot  php -S localhost:2376 -t /var/www/tmp

in windows create bat file e.g phpserver.bat and add to it php -S localhost:2376 -t c:\www\tmp and grape phpserver.bat to startup folder C:\Users\<user name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Comments

0

PHP does provide a single threaded built in web server for development purpose. From php.net....

As of PHP 5.4.0, the CLI SAPI provides a built-in web server.

The web server runs a only one single-threaded process, so PHP applications will stall if a request is blocked.

URI requests are served from the current working directory where PHP was started, unless the -t option is used to specify an explicit document root. If a URI request does not specify a file, then either index.php or index.html in the given directory are returned. If neither file exists, the lookup for index.php and index.html will be continued in the parent directory and so on until one is found or the document root has been reached. If an index.php or index.html is found, it is returned and $_SERVER['PATH_INFO'] is set to the trailing part of the URI. Otherwise a 404 response code is returned.

4 Comments

so how do I go about doing this in the terminal to call a folder on my desktop called php-learning to be the document root
You can use -t in the command line. php -S localhost:8888 -t Users/myname
well the folder I'm actually trying to call is on my desktop it's called php-learning, so would it be php -S localhost:8888 -t /Desktop/php-learning/ ?
Yes it would be your directory path you get in your address bar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.