<? PHP To The Rescue ?>

PHP Development

Development Software

PHP pages can be built and edited with a simple text editor. Some editors are aware of PHP tags, which can color code your source code, once the file is saved with a .php extension. Dreamweaver provides autocomplete, which prompts the developer when typing in PHP functions.  A free windows editor that features autocomplete is Komodo Edit.  For a general purpose free editor, I like the fast, and code friendly Crimson.

Free PHP specific editors include PHP Designer and DevPHP.  The ultimate commercial PHP development environment is Zend Studio.

If you are using a Mac, I have heard people use TextEdit, which is built in and free but not perfect. Another alternative is TextWrangler. There are several alternatives: Mac Editor Discussion

Uploading Your Files

Since our pages should be on the server to run properly, we need to be able to upload the files to the correct directory. For many Unix/Linux PHP servers, the directory is named public_html, referring to the fact that the files that go there are visible to the public, and are generally HTML files.  Sometimes you'll see an alternate directory named htdocs.

A program designed to upload files frequently uses a file transfer standard called File Transfer Protocol (FTP).  FTP is insecure, however, as the login and password information, and all your files are sent via clear text, and can be intercepted.  For customers we recommend Secure FTP (SFTP) which is not offered by all web hosting companies. 

The server we are using for this class (Zephir) requires a Secure FTP application. Therefore, for Windows I recommend WinSCP (Secure Copy & FTP)   (select standalone application). See the following discussion for Mac Software Mac SecureFTP Alternatives 

For general file upload purposes (FTP, insecure) I suggest the Windows FTP programs smartFTP or FileZilla. For Macs, I understand Fetch or Cyberduck  are good choices.

Command Line Access

We'll need to speak directly to the web server to run commands and work with files and directories.  Later we'll use the command line to access MySQL, the open source database system for this class. We'll need to access the command line via a secure connection, and there is a simple program for Windows machines I recommend called puTTY. On a Mac, I understand there is there is a built in Secure Shell (SSH) in OSX

Mac OS X comes with OpenSSH.  To put an alias to "Terminal" on the dock, open your Macintosh HD and go to the Applications folder, then Utilities. Terminal is in the Utilities folder. Drag it to an empty space in the Dock. Next, open a terminal window (from the Dock) and type:

ssh -l horsey01 zephir.seattlecentral.edu

Here's more about SSH on a Mac

File Comparison

The last major software task will allow us to compare files, to be sure of what we're editing.  For Windows machines there's a great program named ExamDiff.  For Macs one such program is KDiff3 

Safe Server Side Programming Habits

With normal HTML programming we are used to working with individual pages. With server side code it is very common to have many pages make up our site. We could have functions included in many pages, dynamic navigational elements that change on the pages and pages that only interface with the database or send email, and are never visible to the user.

With all the extra pages possible, we must take steps to be certain our project is well documented, from the start. With our work, we will require the developer (that's you!) track the purpose and contingencies of each page. (See Assignment 1 of the Homework Page).

Since PHP will not run unless the .php extension is used, always use the .php extension on your pages so you can easily add PHP code to a page at a later time without updating links.

Server Directory Structure

Careful use of the directory structure is an advantage to a developer. Below is the suggested directory structure for your site, with some descriptions of the purpose and contents of the directories:

Directory Name Contents Note
/ (the root, no sub folder) index.php page, main linked php pages End all pages with .php extension, for possible later additional code.  Remember the folder for web files is called "public_html".
/images/ all image files for the site, spacer GIFs, etc. Customary isolation of image files
/include/ All included files, functions, etc. These pages are not visible, and will not be linked
/upload/ all read/write/executable files Isolate any files writable files as the directory that is writable presents security issues
/dev/ All test pages we are using for reference Separate these files from the necessary site files - these files would be removed when a site is done
/sandbox/ all example files we are working on ITC280 class examples go here - these files would be removed when a site is done

Zephir Server

PHP has been enabled on both the "edison" and "zephir" servers for SCCC.  However, our MySQL databases will only be available via zephir.  Please use Zephir to do your class work.   Zephir has been set up to REQUIRE secure FTP. 

When using WinSCP, the hostname is zephir.seattlecentral.edu.  For the User Name use your student name (first initial, first 6 chars of your last name, with a possible replacement of a couple of numbers at the end).  The password is the last 6 digits of your student ID.  Remember the "public_html" folder represents the root of your web space.  The root of your webspace can be viewed on the web (for example) at:

http://zephir.seattlecentral.edu/~username/

Where "username" is your login to Zephir.  Note the tilde (~) before your user name.  Any sub folders would need to typed in from here.

Daily Folders

On your development machine, to keep from overwriting work, and to store work on previous versions of dynamic pages, I suggest keeping daily directories from which to work. This means you create a different directory every day, on your main development machine, with today's date, for example:

/09192004/

The above example would be for the 19th of September, 2004. All of the dated directories should go under a single main folder, perhaps named "Development", and stored in a likely place for backup, perhaps "My Documents".

All work for the day would go into that folder, with work for the next day to be stored in a folder with the next date on it. A time may come in which you need to research all versions of a particular page, and then you can search over all the folders in your development environment. Backing up the contents of all your daily folders and burning them to CDs at regular intervals is advised.

Developer Habits

Backup your files. Backing up files in a server side programming environment is so important that I will require this for the class. Backing up your files does not mean storing your only copy of a file on a floppy disk. By backup, you must have a second copy of all critical files in more than one physical location.

Document your code with extensive comments. At this stage, it is difficult to imagine including too much documentation in your code. Make sure there is a basic description of the page functionality, with dependent pages (if any) listed as well.

Always complete your curly braces before you fill in the applicable code. It is difficult to troubleshoot for this issue, if you don't start with this habit early.

Never work directly on a floppy disk/Network Drive/Thumb Drive. Work on a hard drive, and copy your data to a floppy/Thumb drive, and to the server, thereby fulfilling your "backup" requirement. Never work (in ANY language or even with a critical WORD document), directly on a volatile drive, as you may lose ALL your work!

Create your PHP Spellbook. Create a folder or book with printed copies of all important examples and pages you are working on. Having a printed copy allows you quick access to work you have already created, and allows you to highlight, or draw arrows or notation on a page in a manner not possible in electronic form. The Spellbook is not a requirement for the course, but is highly recommended.

Print this Page Back To Top

© 2000- 2010 newMANIC INC, All rights reserved