Serve a Directory with PHP
Many developers have a giggle at PHP, even looking down at the language, but let's be honest: most of our blogs are powered by it (WordPress) and it's a great language to dabble around with. I cut my teeth on PHP, though I prefer to avoid PHP these days.
But when I need to experiment with a simple PHP coding task for the sake of a blog feature, I look for the simplest possible serving solution to accomplish that feat. Luckily PHP provides me a quick solution for testing:
php -S localhost:8888
The command above allows for serving of a directory via PHP, thus allowing for a simple PHP "site" to be served enough to confirm that my code testing works properly.
Serving a directory with PHP, python, or Node.js ... the same problem solved for different languages!
![How to Create a RetroPie on Raspberry Pi – Graphical Guide]()
Today we get to play amazing games on our super powered game consoles, PCs, VR headsets, and even mobile devices. While I enjoy playing new games these days, I do long for the retro gaming systems I had when I was a kid: the original Nintendo...
![How to Create a Twitter Card]()
One of my favorite social APIs was the Open Graph API adopted by Facebook. Adding just a few META tags to each page allowed links to my article to be styled and presented the way I wanted them to, giving me a bit of control...
![Introducing MooTools NextPrev]()
One thing I love doing is duplicating OS functionalities. One of the things your OS allows you to do easily is move from one item to another. Most of the time you're simply trying to get to the next or the previous item.
![JavaScript Copy to Clipboard with Branding]()
I published a post a year ago detailing how you can copy to the clipboard using JavaScript. The post was very popular and why would it be? Copying content from a webpage without needing to use the default browser functions is awesome. One trend I've...
You can add easily a public directory to it by adding
-t
parameter.Love tips like this, thanks for putting them together!
If you’re using Linux. sudo right is required
To change a current directory function
chdir()
is used. It returns true on success and false on failure. Please note functionchdir()
works in PHP 4, PHP 5, PHP 7. Following is a description of this function.https://www.mindstick.com/Articles/12164/directory-handling-in-php
http://pixelcode.co.uk/tutorials/php/directory-handling-in-php/