Hi and I have learned 2 ways of making a php cms both with simular results on the client side. That is, is it best to have all pages pointed to index.php with mod rewrite and url vars or is it best to have a couple dozen php files each including the styles. Previously I have just placed all my code into the index.php and used mod rewrite to send all url requests to index.php but am now thinking that it might be better to have a login.php and logout.php etc. Which of this techniques do you think is best?

I use a mixture of both. Kind of.

All my calls a centralized around index.php. My url rewrite changes urls like http://www.mysite.com/page/index to index.php?url=page/index. Then my url class grabs $_GET and process it.

My page class loads the proper page from my php folder hidden above the doc root. That ways its organized and hidden.

My file structure:
/private - above the doc root
---- /classes - specific site classes here (like user classes)
---- /css - all css files
---- /javascript - all js files
---- /lib
---- ---- /classes - all main classes (like database, html, ect.)
---- /php - all php files go here. the page class loads them from here.
---- /templates - all templates go here
/public_html
index.php

Thats how my framework is setup. It has worked nicely. I can attach the framework files so you can see how I do it.

Wow, that changes how I think about designing php. I noticed you have a templates directory. Does this mean that there are multiple php files displaying the same template includes from that directory or is it just the index.php that uses the template includes?

Here are the files from my current project so you can see how it works. Its easier to show you than explain.

Here are the files from my current project so you can see how it works. Its easier to show you than explain.

I just checked the code and so oopedy loopedy. As hard as it may be bouncing between the includes/require files I managed to understand the concept. I noticed that nearly all the php code was placed outside the public viewing directory which I have seen the reasons explained before. But all of the php files? Is there an advantage to this or should I only place files that need to be secure outside the web directory because some of the php files would include the banner, footer, menu each in a separate file (I think) so would all of those go above the web directory and be included in index.php? Thanks.

Most of it is personal preference. Configuration files are really the only thing that needs to be protected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.