Using Zend Framework with NetBeans IDE

Posted by Jeffrey Rubinoff on Sep 23 2008, 05:20:22 PM CEST
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.

Category: Tips & Tricks | Permalink | Comments [7]

Trackback URL: http://blogs.sun.com/netbeansphp/entry/using_zend_framework_with_netbeans
Comments:

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

Thanks,
Kevin

Posted by Kevin Bond on September 23, 2008 at 07:47 PM CEST #

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

Posted by Yudi Setiawan on September 24, 2008 at 04:28 PM CEST #

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

Posted by Wil Sinclair on September 24, 2008 at 11:14 PM CEST #

"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.

Posted by Giovanni on September 25, 2008 at 12:36 PM CEST #

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

Posted by Tom on October 04, 2008 at 10:05 AM CEST #

My bad. It works now.
Sorry for bothering you.

Posted by Tom on October 04, 2008 at 10:14 AM CEST #

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.

Posted by links of london on October 30, 2009 at 03:28 AM CET #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed