PHP + Sublime Text

I have been programming in PHP for some years but have recently re-discovered it as a great console-only-output tool. I wanted to put together a quick experiment parsing prices of Amazon and storing the result for later (although I will not go through any PHP code today).
As I found out, it’s really easy to set-up PHP on its own without the need for web servers and browsers.

So, here’s what to do for a bit of fun.

Download and install PHP

Just go to the offical PHP website and download the latest version. I downloaded the thread safe version (as I’m not using IIS) of PHP 5.4.15 binaries for windows. Un-zip it at the root of your C: drive for simplicity.

Then, open the php.ini-development file and save it as php.ini. Edit and remove the “;” at the beginning of line 730 to set the extensions path. I’ve also removed the “;” on line 869 to enable curl, 878 to enable mbstring and 901 to enable sqlite3. I did this to do a bit of web parsing and storing the result in a database but you can enable any extension you want there.

Finally, add php to your system path, in this case C:\php.

Configure Sublime Text 2

Sublime Text is a great simple and easy to use text editor. You can download it on their official website.
Once you’ve installed it, go to Tools->Build System->New Build System. A new document should open up, change it as shown below.

"cmd": ["php.exe", "$file"]

Save it as PHP.sublime-build, the proposed path should be “Document and Settings\User\Application Data\Sublime Text 2\Packages\User\”. Now you should see a PHP item under Tools->Build System.

Write some code, have some fun

All you need to do now is write some code (including some output), change the build system to PHP by going to Tools->Build System and checking PHP, press CTRL-B to enjoy the result.

Brilliantly simple fun.

PHP + Sublime Text

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s