Highlight PHPS code on Nginx

Hey there all,

since I mostly develop in PHP language, I wanted a way to share my code for a while, just to show it to a friend or so, without pasting the code into pastebin.

For such situations PHP created the extension PHPS, which stands for “PHP Source”. on Apache for ex. all you have to do is to add to httpd.conf file the line “AddType application/x-httpd-php-source .phps”, and phps extensioned files will be highlighted.

On Nginx however, there’s no such thing, some will say for good. After a little search i found that many Nginx users already created their own code to highight their PHPS files. but if we make the highlight ourselves, why not to take it into a completely new level? I’ve decided to add more features, such as line numbering. I looked over the www if anyone already wrote such thing. the best solution i saw can be found here. I’ve decided to use it and to add more features, like anchoring the lines, so i’ll be able to point the viewer to a specific line.

I also created a demo, so you can try it without running it yourself.

At last, I uploaded my work, including the Nginx configurations into GitHub, and it can be viewed over here. If you have any ideas to improve the code or you found a bug, I’ll be more than glad to have your feedback!