11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.it-ebooks.infoCHAPTER 24 • INTRODUCING THE ZEND FRAMEWORKinstance, you might want to use an API library not yet supported by the Zend Framework. Just place thatlibrary in this directory and use it as you see fit within the application.publicThe public directory contains the application contents that are directly accessible via the user’s browser.This is an important distinction as compared to the rest of the directories and files found in theapplication’s root directory, which are not directly accessible. You’ll place the application’s JavaScript,CSS, and images in this directory, typically organizing them within appropriately named directories.Within the public directory you’ll also find two files. The .htaccess file is responsible for forwardingall requests to the front controller, which resides in the second file named index.php. This frontcontroller will examine the request and forward it to the appropriate controller for further processing. I’lltalk more about this behavior later in the “Adjusting the Document Root” section..zfproject.xmlThe .zfproject.xml contains an XML-based summary of your application’s file and directory structureas understood by Zend_Tool based on the changes made using the command-line interface. I stress thatthis summary is based on Zend_Tool’s understanding, and may not reflect reality if you happened tomanually add a new controller or model rather than doing so via Zend_Tool. Because Zend_Tool iscurrently unable to detect manual changes, I recommend using the command-line interface as much aspossible in order to maintain an updated .zfproject.xml file. Throughout the course of this project’sdevelopment, I’ll introduce you to new Zend_Tool features; by the conclusion of this chapter, youshould know enough to allow you to use the tool exclusively.Adjusting the Document RootAs mentioned earlier, requests made to a Zend Framework-powered website are processed via the frontcontroller (index.php), which resides in the website’s public directory. Because of this, the index.php filemust essentially intercept all incoming requests, a feat accomplished in conjunction with the .htaccessfile which also resides in the public directory. Therefore, you need to set your web server’s DocumentRootdirective to point to the public directory! For instance, if your application resides in the directory/var/www/contacts, then you’ll set the DocumentRoot to /var/www/contacts/public. This will result in the.htaccess file found in the public directory redirecting all requests to the front controller, which will inturn route the request to the appropriate application controller. Don’t forget to restart your web serverafter making the change.Navigating to the Home PageWith the web server’s DocumentRoot directive set, you should be able to view the application’s defaulthome page. A default home page exists because when the project skeleton was generated, so was acontroller named IndexController.php and within it, an action also named Index. Further, acorresponding view was created and placed in a file named index.phtml. You can find the controller inthe application/controllers directory and the view in the application/views/scripts/index directory.If you didn’t take any special steps to create a custom host for the contacts application and arerunning the application as your web server’s default website, then you should be able to navigate tohttp://localhost/ and see the image shown in Figure 24-1. If you don’t see this image, your DocumentRootdirective is incorrectly set, so check that setting before troubleshooting elsewhere.465

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!