PHP Demo for NB day 2008 (10 minutes)


This demo highlights new tooling for PHP based on the General Scripting Framework (GSF). The demo focuses on advanced code editing features. PHP is still available as a preview available as separate download for NetBeans 6.1.

Product Versions Supported


Points to Hit

NetBeans is getting great PHP support and all PHP developers should give it a try and provide feedback.

Demo Prep


  • Make sure Apache2 and PHP5 run properly before the demo.


Project setup

  • Create New PHP Project | PHP Application.
  • Specify Project Name: PHPDemo.
  • Explain that there are two modes for deployment:
  • One option is to copy files on save to another folder.
  • Choose Project Folder/web as the Project Sources folder.
  • Click Next and show that now you can copy the files automatically to the web root.
  • The second option is to develop the project directly in the www root.
  • Type /var/www/PHPDemo as the Project Sources folder.
  • Explain that you can also create a project from existing sources.
  • The index.php page generation can be disabled (e.g. for existing sources).
  • Explain that user needs to have Apache and PHP installed and these are managed outside of the IDE.
  • Click Finish.

PHP Editing

  • Type ec and show code completion for "echo".
  • Type echo("hello world");
  • Run the project - a web browser window is opened and the hello world page appears.
  • Change the code to:
            $message = "Hello world";
  • Show inplace rename - change the $message string to $my_message.
  • Create a new class - mylib.php.
  • Use the cls code template - this generates a new class.
  • Change the class name to "User".
  • Show PHP code templates in Tools | Options | Editor | Code Templates.
  • Modify the code like this:
    class User {
        function User($name) {
            $this->name = $name;
        function getName() {
            return $this->name;
  • Use fnc code template when generating the function skeleton.
  • Use code completion for $this->name.
  • Go back to the index.php file.
  • Modify the code like this:
            $my_message = "Hello world";
            $user = new User("Roman");
            echo $user->getName();
  • Use code completion for require. It also works inside of the "" and so you can locate mylib.php easily.
  • Use code completion for new User and for $user->getName();
  • Show code completion in strings - at "|Roman" press ctrl-space and show that $user and $my_message are available.
  • Show mark occurences on $user and $my_message.
  • Show navigation - Ctrl-click on require and on getName();
  • Show go to file - Alt-Shift-O and open mylib.php.
  • Create PHPDoc in mylib.php for the getName function using /**.
  • Show code completion on getName() - it will display PHPdoc.

Air alliance sample

  • Create a new project from Samples | Air Alliance
  • Open iterinarymanager.php.
  • Use navigator to jump to the getIterinary() method.
  • Show prioritized code completion - local variables and methods show on top of the list. Mention that it is pretty fast.
  • Go to project properties and choose to copy files into another folder - to /var/www/AirAlliance.
  • Run the application.
  • Go to index.php and change title to Welcome to NetBeans Day
  • Hit refresh in the browser and explain that files got copied automatically on save.


  • Mention that this is just the beginning :)
  • Debugger works also very well - it uses xdebug. No time to show it.
  • NetBeans now has great support for Ruby, JavaScript and PHP. Groovy in the works. Community plug-ins exist for Scala and Erlang. Python/Jython will come next. Future NetBeans will provide comfort for MANY programming languages.
  • It was possible to write such PHP support in less than 3 months - the team rewrote PHP support on GSF.

Demo Cleanup

  • Delete the project you just created.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo