Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using Zend Framework classes with code hints

From: Dreamweaver with PHP and MySQL

Video: Using Zend Framework classes with code hints

After configuring your third-party library, you can then use the code hints that are implemented with Dreamweaver to more easily and accurately do your PHP hand coding. For this demonstration, I'll use a version of my site in the folder 03_managingcode/05_sitecodehints, and I'll point my site to that folder. When you configure site code hinting, a file is added to your site, named dw_php_codehinting.config.

Using Zend Framework classes with code hints

After configuring your third-party library, you can then use the code hints that are implemented with Dreamweaver to more easily and accurately do your PHP hand coding. For this demonstration, I'll use a version of my site in the folder 03_managingcode/05_sitecodehints, and I'll point my site to that folder. When you configure site code hinting, a file is added to your site, named dw_php_codehinting.config.

You can open this file in Dreamweaver, and you'll see that it's a simple text file that includes listings pointing to the absolute folder locations that contain your third-party files. If you're working on Mac OS X with MAMP and you placed the Zend Framework in the location I recommended, under the MAMP installation folder, in this file, you can change every instance of c:/phpincludes to /applications/MAMP. There is more information stored in the background; this file wasn't the whole story. But this is how you can tell that your particular code hinting setup has been added to the site.

I'll demonstrate using code hinting by using your class named Zend_Date. The Zend_Date class is a PHP class that does a lot more than the standard PHP date class. I'll be adding the code in a file called DateUtility.php. This file is being included and used in a file called footer.php already. In the current version of the file, I'm setting the time zone and using the PHP date function to output the time in the current format.

I'm going to add the use of the Zend_Date class here. The first step, before you can use any of the features of any PHP class, is to include the file that defines the class. You typically do this with a PHP command called include_once. I'll place the cursor at the line that has the class declaration and then create an empty line above it. Then I'll type in include_once, and then after an opening parenthesis, I'll add the relative location of the date class I'm interested in.

I've already configured my PHP installation to automatically include anything in the Zend framework library. So all I need to de here is start off with the Zend folder, and then after a forward slash, name the class that I want to include, Date.php. If you're not sure of the names of the PHP files, take a look at the phpincludes folder, at the ZendFramework library folder, and then go to Zend. Down at the bottom, you'll see a whole listing of all the files that should be included.

I'm including this one, Date.php. This file in turn includes all of the classes that are required: the DateObject, Locale, Format, and Math. It's up to the Zend framework to go and get all the resources it needs for all of the complex features that are implemented. I'll close these windows and return to Dreamweaver. So I've included the definition of the date class. Now, I can use it in my PHP code. I'll place the cursor inside the getCurrentTime function and press Enter to create a new line, and next, I'll create an instance of the Zend_Date class.

I'll create a variable named zendDate - you can name this variable anything you want - and then I'll use the new keyword and then type the beginning of the class name. All classes in the ZendFramework library start off with the word "Zend." So I'll type in "Zend" and an underscore, and then I can scroll down and select the class that I want. I'm going to use Zend_Date. I'll type in an opening parenthesis, and I'm showing that there are three possible arguments, or values I can pass in: date, part, and locale.

I'm going to ignore those properties for the purpose of this exercise, and not pass in any values. When you create a new instance of the Zend_Date class without passing in any properties, it represents the current date and time on the server. So, now I have a copy of the class, and I can call its functions. I'll place the cursor down toward the bottom of the function, after the last echo command, and I'm going to add a couple of echo commands that output some literal text. The first one will add a
tag.

Make sure that you include semicolons at the end of every line. The next echo command will output some literal text: The current date is, and then I'm ready to use a feature of the Zend_Date class. Once again, I'll use the echo command, and then I'll use zendDate - that's the name of my variable - and then put in the dash greater than, and I'll see a whole listing of all the features of the Zend_Date class. You'll see that there is an enormous set of methods that you can use to manipulate and inspect various date values.

First, I'm going to use the get method. The get method allows you to output the raw value of the zendDate object. I'll save the change, and then I'll open the file that's using my date utility class, footer.php. I'll look at this file in Live View, making sure that I update the server, and then I'll scroll down in the Live View and show that the current date is being output as a raw numeric value. This is the number of milliseconds from what's called the epoch date of the date object.

Well, that's not exactly what I want to show the user. Instead I'd like to show them a friendly date output. So I'll exit Live View and go back to my code, and I'll go back to DateUtility.php. Instead of using the get method, I'm going to use another method called toString. The toString method, once again, can take a few different arguments: a format, a type, and a locale. I'm going to use a format this time of MMMM and a space, then a lowercase d, a comma and a space, and four Ys.

These are masking values that mean the full name of the month, the date as a numeric value without padding, and a four-digit year. I'll save those changes and then go back to footer.php and look at the files in Live View, copying them to the server, and here is the result of using the Zend_Date class; I'm now getting a nicely formatted date. You'll find that the utility classes in the Zend framework are much more powerful than their raw equivalents in the PHP core libraries.

Many developers like using the Zend framework only for these utility classes, while other developers like to use the entire capability of the Zend framework, which allows you to build complex, well-architected applications, using an application architecture known as Model-View-Controller, or MVC. However you use the Zend framework, Dreamweaver CS5, through its site-specific code hinting, will help you get your code right the first time, both for the Zend framework and for any other third- party PHP libraries you decide to use.

Show transcript

This video is part of

Image for Dreamweaver with PHP and MySQL
Dreamweaver with PHP and MySQL

61 video lessons · 36331 viewers

David Gassner
Author

 
Expand all | Collapse all
  1. 8m 48s
    1. Welcome
      1m 25s
    2. What you should know before watching this course
      2m 17s
    3. Using the exercise files
      1m 40s
    4. Understanding the differences between Dreamweaver CS5.5 and CS6
      3m 26s
  2. 19m 31s
    1. Understanding static vs. dynamic web pages
      4m 32s
    2. Selecting application and database servers
      6m 10s
    3. Introducing Apache, MySQL, and PHP
      6m 36s
    4. Installing Apache, MySQL, and PHP
      2m 13s
  3. 39m 34s
    1. Defining a Dreamweaver site
      3m 22s
    2. Configuring a PHP testing server
      7m 48s
    3. Creating and testing a PHP-based web page
      8m 25s
    4. Adding PHP commands with the Insert panel
      3m 14s
    5. Setting and outputting simple variables
      3m 56s
    6. Testing pages with Live view and Live Code view
      2m 9s
    7. Using server-side includes
      7m 50s
    8. Navigating included pages with the Code Navigator
      2m 50s
  4. 36m 37s
    1. Using code hinting with PHP variables
      5m 31s
    2. Understanding PHP custom classes
      6m 38s
    3. Adding Zend Framework to PHP on Windows
      5m 18s
    4. Adding Zend Framework to PHP on Mac
      4m 2s
    5. Using the Site-Specific Code Hints feature
      3m 43s
    6. Using Zend Framework classes with code hints
      7m 26s
    7. Managing reusable code with the Snippets panel
      3m 59s
  5. 18m 27s
    1. Understanding relational databases
      5m 26s
    2. Creating a MySQL database in phpMyAdmin
      4m 41s
    3. Adding data in phpMyAdmin
      2m 46s
    4. Importing a completed database from a script
      5m 34s
  6. 39m 35s
    1. Defining a Dreamweaver database connection
      5m 27s
    2. Building a simple recordset
      4m 31s
    3. Building an advanced recordset
      5m 1s
    4. Displaying data with repeating regions
      6m 4s
    5. Displaying data in a dynamic table
      4m 15s
    6. Formatting dynamic data
      4m 54s
    7. Displaying the total number of records
      2m 4s
    8. Limiting records with paging controls
      4m 5s
    9. Creating conditional regions
      3m 14s
  7. 43m 12s
    1. Building a simple data entry form
      5m 27s
    2. Handling form submissions with PHP
      5m 12s
    3. Creating a customer email form
      3m 9s
    4. Validating form controls with Spry
      7m 54s
    5. Populating a list control with dynamic data
      4m 50s
    6. Working with multiple checkbox controls
      8m 5s
    7. Sending email with Zend_Mail
      8m 35s
  8. 50m 51s
    1. Using data wizards
      6m 20s
    2. Formatting dates for SQL
      5m 27s
    3. Creating a custom data entry form
      4m 50s
    4. Preparing a database table for server behaviors
      3m 3s
    5. Using the Insert Record server behavior
      5m 42s
    6. Preparing an update form
      7m 6s
    7. Using the Update Form behavior
      5m 46s
    8. Creating list page links to edit and update data
      7m 3s
    9. Using the Delete Record server behavior
      5m 34s
  9. 14m 45s
    1. Creating a login form with a PHP server behavior
      6m 29s
    2. Protecting page access with PHP server behaviors
      4m 17s
    3. Logging out with a PHP server behavior
      3m 59s
  10. 22m 50s
    1. Configuring a remote server with FTP credentials
      4m 42s
    2. Synchronizing site assets with the remote server
      5m 27s
    3. Exporting the MySQL database to a script
      3m 8s
    4. Importing the MySQL database on a remote server
      2m 24s
    5. Configuring the site for the remote database
      7m 9s
  11. 52s
    1. Final thoughts
      52s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dreamweaver with PHP and MySQL.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.