Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this movie, we'll establish the project work area for our content management system. That is, we're going to create the directory structure that we can use to put our php files in while we're developing. Up until now, we've been using the sandbox directory and that's what we've been accessing. That's still going to be useful to keep around. That's going to be a place that you can refer back to if you want to see how we did things. It's also a place where you can try out things. I use a sandbox like this all the time. Just a place to Jump over to do a quick experiment. And then jump back to my project again. But I'm going to fold that up. And we're going to create a new directory here that's going to be for our project.
I'll make another one, called Stylesheets. Some people like to call theirs simply CSS. These are going to be my asset folders, and it's a place where I can just quickly drop the assets that my website's going to need. Your website might have more. If you have PDF files or movies, you might have additional folders for each of those kinds of assets. But it's good to have these right at the start. I'm going to create another one. I'm going to call this one Includes. This is where I'm going to drop all the little bits of code that I'm going to include into my PHP pages. So, if for example, I have a database connection, I want to pull up the username and password and everything that I need to connect to the database. That would live in my Includes folder.
Now I'm just going to open up a new folder here and go back into Sites and then into Sandbox. I'm going to grab that basic HTML file. I'm going to Option drag it over just to make a Copy and then I'm going to just change the name of this to be Index and change the file extension to be .php. When I hit Return, it comes up and says Are you sure you want to make a PHP? And I'll say Yes, I'm sure. Now most web servers, by default, will load up a page that's called index.html or index.php. So that's what we're doing here. This is going to be the default page that people will get when they come to our website.
Now I'm going to go ahead and create another version of this, I'm just going to do a duplicate on that. And I'm going to call this one, instead, admin.php. And I'll make one more duplicate and I'm going to call this one manage content.php. There we go. So those are going to be three placeholder pages that just have a bit of HTML in them, that are ready for me to start populating. Here's the main page of the website. It's going to be the Menu page for the Admin area. And this is going to be the page where we're going to start putting our CRUD for managing our content in our CMS. Now there's one more folder that I want to add and this one is super important. I'm going to call this one public.
Now when I talk about public here I'm not talking about the public as opposed to the admin area. This is not for the public area. What I mean here is for the public at large including our admins. This is for anyone on the internet. It's basically saying this is public as opposed to private. These are things that I assume are publicly accessible to somebody. Then I'm going to take all of these files except for public and for includes and I'm going to drag them in there. So now, public contains all of my php pages and all of my asset directories. This makes it clear the division between the code that the public should be able to access and the code that they shouldn't.
For example, we're going to want to put our database, username, and password in the Includes folder, so that the public can't see it. And then we can still include it or require it whenever we need it. We have access to the file system, and PHP can go backwards a directory in order to find it. But the public can't do that. They're not going to be able to do that from the web server. They will only be able to see things that are inside public. On the other hand the things that are in the public directory are HTML, our asset directories, style sheets, java scripts and images are going to be accessible to everyone. Now this is going to take a little bit more configuration.
When you deploy this to the internet, you're going to tell your web server to link up your domain name with a directory. So, www.mysite.com. You're going to want to point it to public not to widget corp, point it to public. That's going to tell it that everything in here is what it should serve up. All the things here will still be considered private. It's a very useful and important security technique and I want to make sure that we start using it right from the start. Okay now that we have the fundamental structure for our CMS, we're ready to create and style our first page.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105206 Viewers
56 Video lessons · 116982 Viewers
71 Video lessons · 86183 Viewers
131 Video lessons · 41208 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.