File Structure

Ask about a PHP problem here.
Post Reply
User avatar
DomC
Posts: 91
Joined: Mon Jul 18, 2011 1:58 pm

File Structure

Post by DomC »

Would it be possible for someone to explain Jacek's file structure and also feel free to tell us your own if you have a different one.
Thanks in advance!
Dom
I can't think of anything witty to put here!

Check out some of my projects on GitHub: https://github.com/DomTC
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: File Structure

Post by jacek »

What do you want explaining exactly ? I do it in pretty much every video don't I :?
Image
User avatar
DomC
Posts: 91
Joined: Mon Jul 18, 2011 1:58 pm

Re: File Structure

Post by DomC »

Yep, but I don't really understand what you out in your core folder and what you put in the initial folder.
I don't really get the difference if that make sense - I hope that makes sense!
Dom
I can't think of anything witty to put here!

Check out some of my projects on GitHub: https://github.com/DomTC
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: File Structure

Post by jacek »

Okay, well. the "core" folder contains all of the code that makes up the backend of the system. So this is generally just a lot of include files. In there core folder, there is init.inc.php which is included by all pages which are in the root, this init file just does things that need to be done on all of the pages (session_start() for example) it also includes all of the files in the "inc" folder. The files in this folder provide functions that are specific to the site (in the blog tutorial there was a file for dealing with posts).

That is basically what I say in the videos, and I think where you are confused is you don't get why the file in the "inc" folder don't just go in the "core" folder directly. The reason for that is that in the core folder there will sometimes be a config.inc.php file and a lib folder, this is generally for bigger projects. The lib folder will contain files similar to the ones in the inc folder except that they are not specific to the site, so there could be a file that does a mysql thing or escapes a string according to if magic_quotes is on or not. And the config file just holds any settings for the site that the site admin may want to change in the future, the database connection info is a common example of this.

It makes a bit more sense to have all these folders for a larger project really, but I wanted to use it for everything to demonstrate a bit of consistency, plus it is the structure I actually use when developing.
Image
User avatar
DomC
Posts: 91
Joined: Mon Jul 18, 2011 1:58 pm

Re: File Structure

Post by DomC »

Ah, thanks I understand now! And I think you where right about me being confused by the Inc folder in the core folder, but now I understand that their would be other folders as well and everything is clear.
Thanks again
I can't think of anything witty to put here!

Check out some of my projects on GitHub: https://github.com/DomTC
User avatar
Linkjuice57
Posts: 23
Joined: Tue Jul 12, 2011 2:44 pm

Re: File Structure

Post by Linkjuice57 »

Aha, I always wondered that myself also. I personally just throw everything in an /inc/ folder :lol:
non-existent PHP newb
Post Reply