开发者

How should I manage a PHP database-driven website with lots of pages/content?

开发者 https://www.devze.com 2023-04-01 17:42 出处:网络
Let it be known that I only have experience making websites with 5 or 6 pages. I\'d like to make a PHP Gaming journalism site like http://www.escapistmagazine.com/

Let it be known that I only have experience making websites with 5 or 6 pages. I'd like to make a PHP Gaming journalism site like http://www.escapistmagazine.com/

The first problem I can think of is that I would have to manually make a page for each game article; that path was obviously not going to work so I decided to store all the articles in a database.

The problem with storing the content in a database was figuring out how t开发者_JS百科o retrieve them. I attached a GET variable to the url so I could retrieve any article from an index.php file; however, I could not hide the GET variable from the url so I ditched that method. I have no free cash to buy a CMS and I have tried free ones like Drupal to great frustration.

Do I have to generate a separate php file for each article? What would a professional/veteran do in my situation?


First, I'd like to state that if you are having trouble finding the patience to set up Drupal, Wordpress or similar free CMS', you would be hard pressed to find the patience to creating one from scratch.

Having said that, to address the specific request you're looking for, I believe you want to use mod_rewrite to funnel your requests through a single file, which would, in turn, hand the request off to the appropriate file. Drupal, for instance, uses the following rules:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Which routes your URL into a single variable, 'q'.


I manage a CMS that publishes PHP pages statically like you're considering. Coming from MVC designs, it is horrific, and I highly suggest you not take that route.

I'd check into one of the frameworks like Code Igniter, Cake, or if you feel like you want to torture yourself, Zend. All joking aside, you'll be able to create routes that use the URL request to find the content that you're looking for. I won't go into the whole concept of MVC and routing here, as it is well documented throughout the web, but essentially it keeps template management much easier. As a matter of fact, pretty much everything is easier, and your codebase stays much cleaner.

Right now, I've got a codebase for my CMS of almost 400mb. This is because there's an abundance of static pages that are indexed. This would be cut significantly to ~50mb (if that) if I converted it to an MVC framework. Keep in mind, this is without user generated content like PDF, MP3, etc.

If that seems scary, I highly suggest using Joomla!, Drupal, Wordpress, or any of the other CMS systems out there. Trust me, you'll save a ton of time.


The best advice I could give you: use Wordpress, don't rebuild it yourself. It's really perfect for this job.

Bottom line: 15% of the best websites run using Wordpress.


When you start considering security, maintainability, time, and other factors - for what you are describing I would just use WordPress. Free, easy to setup and proven. It's not just making the frontend site for your viewers, you also need all the admin tools to manage it all as well.

If you do build your own, you will want to use a database to store your data. You won't create a php file for each article, you will most likely have one or few php files that focus only on loading an article page from the database using rewrite rules for nice urls. Good luck with the path you choose.

0

精彩评论

暂无评论...
验证码 换一张
取 消