Run PHP in command line in Netbeans

netbeans-logo

PHP is a web programming language, but sometimes you may want to run PHP as script (in the command line,) in the other words not showing the results in browser. You can actually do this in Windows environment with Netbeans. Here is how,

1. Grab an PHP interpreter – The easiest way is to download WAMP server
2. Define PHP interpreter for NetBeans – Go to Tools > Options > PHP, and then set up your PHP interpreter, as shown in the following figure.
project-properties-netbeans
3. Set Run Configuration for your project – Right click on your project > Click Properties OR set Properties when you create a new project, and set Run As to be ‘Script (run in command line) as shown in the following figure.
project-properties-netbeans
4. Pretty much those are what we need, but remember when you run a script, don’t use “Run Project” button on the toolbar, instead, right click on the Source window, and click ‘run file’, as shown in the following figure.
run file in netbeans

That’s it!

Leave a Reply

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