Join Kevin Skoglund for an in-depth discussion in this video Project setup, part of PHP: Object-Oriented Programming.
- [Narrator] In this movie, we'll get our development space set up so that we can learn object oriented programming. The first thing that we'll want to do, is make sure that you know where your web document root is. That's the default directory that your web server will use to serve up documents to the browser. If you've been working in PHP chances are you know where that is right away. That's the place we're going to be locating our files. And of course you'll want to make sure that PHP is running as well. We'll do a quick test of that together. After that, in chapters one through six, we're going to be doing our learning inside a demonstration directory called oop_sandbox.
This directory will be a place where we can put all of the examples of the different concepts as we're learning them. It'll give you a convenient location where you can refer back to those concepts if you need reference and it'll provide a space where you can experiment on your own, if you want. I frequently use these kinds of sandbox directories to perform experiments of my own. Another reason we'll do it this way is because if we were to try and create an actual project there's almost no chance that any project would use all of the techniques that we'll learn. So this will give us a chance to actually try out all of the techniques and then later starting in chapter seven, we're going to use a project it's going to be a website for a company selling used bicycles.
That will give us the opportunity to apply the object oriented programming techniques that we've learned to something that's more like a real world scenario. So the first step is to locate the web document root. For me that's going to be inside my user directory. Inside my sites directory. So this is where I am going to be putting all of my files. And you can see here, I have the oop_sandbox directory, that's included in the exercise files. But it's also very simple. It's just got a couple of files in it. I'm going to drag that directory on top of the Atom text editor, so that I can open it up inside Atom.
And then in Atom I'll be able to look at it in a project view. You'll see that I've got this basic.html file, which is just a simple html template that we can grab and reuse as needed. I frequently have those in my projects as well. And then we've got php_test.php and this is a page to launch a test to make sure that we've identified our web document root. And that PHP is working. If it is working then it'll just simply call this bit of PHP to say that it's working. So let's try it out. Let's now save that file. Let's come over to Firefox.
And the default location for me is going to be localhost and then my user directory, Kevin Skoglund. Now, for a lot of people, if you're not on a Mac, you probably aren't going to use the user directory. You'll probably just have localhost and then right after that the directory oop_sandbox and then the name of that file which is php_test.php. If you were able to get that file back, it says PHP is working, then you'll know your files are in the right place. And you have PHP up and running and you're ready to go.
If not you'll need to troubleshoot it to find the right web document root or to get PHP up and running.
- Defining classes
- Calling methods
- Class inheritance
- Extending and overriding classes
- Accessing and controlling access to properties and methods
- Static properties and methods
- Magic methods: constructor, destructor, and clone
- Creating a PHP OOP project