Join Jon Peck for an in-depth discussion in this video Exercise files, part of Object-Oriented Programming with PHP.
- View Offline
In this course, we'll be using PHP on a web server that uses a database. I recommend using Apache 2 or higher as the web server. The code should run on other web servers like NGINX or IIS, but I won't be demoing with that configuration. For the database, use MySQL 5 or above. Finally, you'll need PHP 5.3 with the MySQLi extension installed, which should be there by default. Setting up a development server is out of the scope of this course. If you need one, I prefer a virtual dev server running on my workstation, like the one shown in Up and Running with Linux for PHP Developers here in the Lynda.com Online Training Library.
I'll be demoing using this configuration. If you'd like, a local web server stack package will also work. XAMPP from apachefriends.org has distros for Mac, Windows, and Linux. There's also WampServer from wampserver. com, which is only for Windows and MAMP from mamp.info for Macs only. All three of these stacks will work for this course. If you'd like to learn more about local web stacks, check out Installing Apache, MySQL, and PHP with David Gassner here in the Lynda.com Online Training Library.
If you'd prefer not to set up a local dev environment, third-party hosted servers will work as long as they have the appropriate versions of Apache, MySQL, and PHP. This is a common configuration, so finding a host shouldn't be a problem. The exercise files for this course are arranged in folders by chapter and movie. On my workstation, I've put them in a folder on the desktop named 'sandbox' that my virtualized Linux server can access. Depending on your config, your location may be different. Regardless of your setup, you'll need to import the contents of the free sample data in demo.sql into a database that you have access to.
This file contains the schema and sample addresses. To follow along with the demos, you'll need a way to edit your PHP code. I'll be using the free IDE NetBeans 7.1 for PHP from netbeans.org. NetBeans is not required for this course, but it may be easy to follow along if you have it. Finally, as different web hosts and configurations serve content from different URLs, the address you'll be seeing in my browser may not be an exact match from what you see on your workstation. With that said, the end result should look about the same.
- Historical overview of object-oriented PHP
- Defining classes
- Creating a method/object context with $this
- Accessing classes without instantiation
- Creating a database class
- Extending and abstracting classes
- Cloning and comparing objects
- Error handling with exceptions
- Implementing design patterns, such as the factory and strategy patterns