How to use things like Fat-Free Framework with “php -S”

Having grown very used commands like these, nobody was more eager than I when PHP 5.4 introduced its own no-setup development server.

  • python manage.py runserver (Django)
  • paster serve --reload (Pylons)
  • nodemon (NodeMon for Node.js)
  • jekyll --auto --server (Jekyll, used by GitHub Pages)

However, in typical PHP fashion, there’s some assembly required and you’ll probably need code from either the comments or somebody’s blog to get it to behave the way you’d expect it to by default.

So, without further ado, here is what I came up with to get the basic “excise index.php from the URLs and pass static files through” behaviour most people use .htaccess for.

(There is a command-line option for this sort of behaviour, but it doesn’t match the behaviour of the net’s most ubiquitous mod_rewrite snippet.)

It’s been tested under Fat-Free Framework 2.0.6 through 2.0.12 and, if there are any incompatibilities with other frameworks or PHP applications, they should be minor.

CC BY-SA 4.0 How to use things like Fat-Free Framework with “php -S” by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

This entry was posted in Geek Stuff. Bookmark the permalink.

1 Response to How to use things like Fat-Free Framework with “php -S”

  1. JZ says:

    Thanks for letting me know about Fat-Free Framework . Pretty useful for me as an average php programmer.

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution under the same terms as the associated post.

All comments are moderated. If your comment is generic enough to apply to any post, it will be assumed to be spam. Borderline comments will have their URL field erased before being approved.