X

An Oracle blog about NetBeans for PHP

Using Zend Framework with NetBeans IDE

I was messing about trying to get Zend Framework to work with  NB 6.5 Beta. I made many small mistakes, being a complete n00b to PHP, but with much help from the PHP team, I got the Official Zend Framework Quick Start to work.
Some things I did and some mistakes I made are worth noting.
  • I created the project in my NetBeansProjects folder and had metadata saved to the same location, which was the default option. The Apache server cannot expose PHP files from there, so I had the sources copied to my Apache root directory, which in my case was XAMPP_HOME/htdocs. I could have created the project directly in XAMPP_HOME/htdocs, which was the default option. I have a ton of non-PHP projects though and like having all projects in the same directory.

  • I added the path to Zend libraries globally for all PHP projects, through the Tools > Options > PHP window.

    Alternatively, I could have added the libraries to the PHP include path of the individual PHP project, through the project's Properties window.
  • I created the folder structure as described in Official Zend Framework Quick Start, but I left out the /library folder because I thought that was taken care of when I added the Zend libraries to the IDE's global Include Path. Neither did I specify the path to the Zend libraries in bootstrap.php.

    I was wrong. The IDE's Include Path only enables libraries to be used in code completion. It does not pass the libraries to the Apache server. So I had to recreate the folder structure and bootstrap.php exactly as described in the tutorial, meaning that I copied the Zend libraries to the /library folder in my project and put that folder on the include path in bootstrap.php. I found that the IDE did not copy the Zend libraries from my project folder to XAMPP_HOME/htdocs/QuickStart/library--this may be a bug--so I had to copy them manually to that location, too. I am not sure that I need the libraries in my NetBeansProjects location or only in XAMPP_HOME/htdocs, but I have them in both locations to be safe.

    My final project structure looked like this:

  • Thanks to the complications of my directory structure, the final URL was http://localhost/QuickStart/public/index.php. In a proper PHP environment, this URL would be shortened by setting up a virtual host on Apache. However, I have not yet educated myself in how to do this.

Aside from these points, I was able to complete the Official Zend Framework Quick Start as it is written. Next I will try a more complicated Zend Framework tutorial.

 Note: Crossposted in my personal blog.

Join the discussion

Comments ( 15 )
  • Kevin Bond Tuesday, September 23, 2008

    This is great! I was just at zendcon last week and was inquiring at the Sun booth about this.

    Thanks,

    Kevin


  • Yudi Setiawan Wednesday, September 24, 2008

    Thanks for the article & sharing your experience.

    It's really helpful.

    Btw, I tried the Official Zend Framework Quick Start link (http://framework.zend.com/wiki/display/ZFDEV/Official+ZF+QuickStart), but it displayed "Page not found" error.

    I think the link may have been changed to http://framework.zend.com/docs/quickstart ?

    Thanks


  • Wil Sinclair Wednesday, September 24, 2008

    Yes, indeed. We removed the old tutorial after making the migration to the main site. BTW, we always planned this migration, but I couldn't find the time for months. :( I hope you like the new QuickStart!

    ,Wil


  • Giovanni Thursday, September 25, 2008

    "So I had to recreate the folder structure and bootstrap.php exactly as described in the tutorial, meaning that I copied the Zend libraries to the /library folder in my project and put that folder on the include path in bootstrap.php"

    for an integration of the zend framework in netbeans I'd suggest to plan a setup that let the user keep the zend library folder outside the project folder so that he can share that folder with many projects in development environment..

    you can still use the library folder changing a couple of defines in the index.php file (and maybe in bootstrap.php too)

    example (index.php, line #5):

    define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/app/'));

    set_include_path(

    APPLICATION_PATH . '/../../../zf/library'

    . PATH_SEPARATOR . get_include_path()

    );

    You should then have this code auto-generated from the netbeans wizard (please let the user choose whether to use absolute or relative path)

    bye,

    Giovanni.


  • Tom Saturday, October 4, 2008

    I started index.php

    <?php

    echo "Hello Zend Framework";

    Then run a project and a box is opened with information

    "Index file must be a valid file"

    But if i check zend pages:

    http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html

    B.2.1. General

    For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response.

    Version of IDE:

    Product Version: NetBeans IDE Dev (Build 200810031107)

    Java: 1.6.0_07; Java HotSpot(TM) Client VM 10.0-b23


  • Tom Saturday, October 4, 2008

    My bad. It works now.

    Sorry for bothering you.


  • links of london Thursday, October 29, 2009

    It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.


  • Hung Hoang Tuesday, December 15, 2009

    I am new to netbeans and I am trying to get familiar with it. My question is, in netbeans when creating a new project, do I alway have to create the folder structure or it usually automatic create it when creating a project?


  • simukti Monday, January 18, 2010

    great ! but, is Netbeans can automatically create default Zend Framework folder structure too? thanks


  • Nguyen Thanh Tung Thursday, January 21, 2010

    Thank you for this article. It helps me on NetBeans code completion. Just add ZendFramework path to Global Include Path.


  • deerawan Sunday, March 14, 2010

    nice post..I've just thought to switch from aptana to netbeans


  • Patabugen Monday, July 19, 2010

    To avoid the silly long URL's you can set the Web Root by right clicking your project and clicking Properties.

    Set this to the 'public' folder of your project and NetBeans will know to use http://localhost/index.php instead of http://localhost/public/index.php


  • guest Saturday, September 24, 2011

    Thank you for this article. It helps me on NetBeans code completion. Just add ZendFramework path to Global Include Path.


  • Dan Wednesday, April 11, 2012

    Since NetBeans 6.9 of course you've been able to integrate the Zend Tool into NetBeans to create projects and execute commands.

    Can be a bit fiddly to set up, so I put together a simple guide on it - http://www.webdevguides.co.uk/zend-framework/using-zend-framework-in-netbeans-ide


  • guest Wednesday, February 5, 2014

    I want to know procedure of installing zend framework in wamp.

    I have zend framework folder but not has no library folder in it.

    please mention the procedure to install zend in project and change in php.ini and if needed in apache or anything. please....


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services