Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Konrad Pilch
Konrad Pilch
2,435 Points

File structure PHP dynamic website

HI,

Im making a website, like treehouse/facebook. The purpose of the website is to be able to log in/out ,having user profile, having topics, categories , posting new things , deleting, and u get the idea.

So , how should i strucutre my folder files? any good practice for it?

What im doing is just :

FOLDER............::::::........INSIDE
ASSETS | css, fonts ,js
CORE | init ( database )
HELPERS | db_helper, format_helper, system_helper
LIBRIARIES | daabase, user INCLUDES | includes -> header & foter , register and frontpage in html Not in folder | index, login, logout, register ( only php code here ) .

So if im creating a website like treehouse, with login functions, user fnctions, forum functions , how would be the best for file strucutre to look like?

Scott Evans
Scott Evans
4,236 Points

You have the right idea with your current structure, although one thing i would suggest is to put and of your libraries / core outside of the public domain. Therefore stopping people from accessing your PHP Classes / Scrips directly.

What sort of experience do you have with Programming design concepts?

Konrad Pilch
Konrad Pilch
2,435 Points

You mean to put the libraies and core folders, outside the public domain? so where should i put it ? im using ecowebhosting but should it be outside the folder of public domain but still there?

And well, im pretty new in it , everything im doing now, its a big step for me, lot of effort goes in. Same as you learned CSS first time, then the second time, you could do it okay.

I havent done it yet, although i did actually maybe one or twice? when the user logs in, the header registration desapears and apears something else, though i have no idea where i put the code , i do a lot of folders where i try new things so its stupid simple to understand .

Although what im doing here, it to put everything as an object, chop it out . Meaning if we have treehouse webiste , we can see on the left the side bar , lets say that it only apears if your logged in , so when the user is logged in , show this with and if statement i guess. Or if the user is logged in, hide this left bar .

Thats the righ idea?

Its very exciting, but its actually hard to do it .

My plan now is to make a simple website, with some modals as well, using bootstrap and make a log in , then do something with it you know, to learn new stuff . I know how to make a log in system at the moment and display " Hello , <name> . You are logged in . Now i would like to try to make something like user information when yo uclick mine profile, you get his user , liek you get the idea . I hope i can do it , I still find hard parts in PHP with the parts i havent worked nor i know why they are there but i will post the code if i will want to put it on production . Hoping to get some comments, and whatever, i think the stuff i was looking, qould be even more advanced than what im doing now maybe , but i still have to learn how to do categories as well as every user having its own post so others cant delete it. Its very simple to use SQL to delete and stuff so that wont be a problem but the way i use OOP well, thats new challenge : p plus i hope i can find some tutorials as well since treehouse is kind of too basic now in some parts that dont strech farward .

I looked at laraver , but i will learn it in two months since this PC is not mine and its windows as well, and in 2 months i will have iMac back .

Probably , i could learn wordpress PHP i believe . i jsut went out of topic or rather what you were asking me , i beleive : p

btw, what do you mean public access? do you mean , i could look at the whole codeof treehouse, that its made public ? and things like security, they would store it in different place?

When i go onto my domain, i can put stuff inside the public folder and outside it, do yo umean to put it outside ?

Konrad Pilch
Konrad Pilch
2,435 Points

Or did you mean design as with JavaScript? if so , not really. I know JS basics and stuff, i could look at the code , but i would need to dive in to learn more about it. I like JS sinceit shares concepts from PHP and things like getElementById or class , you know, simple . Plus the if etc.. you know, cocepts from PHP in JS , maybe JS is harder , but i believe learning it after PHP would be much easier as well.