tags:

views:

179

answers:

6

I've been wanting to build my own gaming community site (like http://fragbite.com) for a long time. I have started many times but just quit after a couple days because it gets very messy.

I've been playing around with PHP and MySQL off and on for 3 years, but I've never gotten in to OOP. I have tried, but I usually end up with the "old PHP".

I usually build my pages so that I include a file on top of all pages with necessary functions, html head etc. and I mix php and html together which I don't mind, but if I eventually would get a designer he would not like it I think.

I have tried both phpcake and codeigniter and all those popular mvc's but it's just too much, like they do all the work. I want to do it myself, but I don't know where to start.

What would you do if you were me? Is there maybe some non-oop mvc?

(Sorry for my English)

A: 

I didn't try to build a gaming community but I did build something. I found cakephp to be too heavy weight for my tastes so I rolled out a nano framework (something like web.py for python) and I was that much happier.

Here are a few examples:

Basically a nano framework consists of 2 important concepts:

  • A url-to-class mapping system.
  • A page renderer.

Some people will tell you that it's not worth rolling your own and doing all the work yourself but it's really a matter of personal taste. I think rolling your own is more personal and you understand more of the inner workings than you would have the other way around. It's also a vastly more educational experience and I'm all about education. But.. to each their own.

P.S. Not very relevant but I also used nginx and postgresql over my usual choices of apache and mysql (I have no problem with apache and mysql I just thought I'd try something new). The results were remarkable. :)

Of course they took a bit of work to get going but nothing good ever came easy.

Fake Code Monkey Rashid
+2  A: 

Maybe that's not really the answer you'd like, but I think you should take a better look at MVC and MVC's oriented Frameworks.

You spoke of some ; you can also have a look at others, like :

I agree, there is some (at least a couple of days for the basics ; weeks, I'd say, to really understand them, and use them well) learning curve, and they do much work for you...

... But them doing much work allows you to concentrate on what really make your application ;-)

I would also say two more things :

  • Using that kind of framework really makes modifications and maintenance easier (I really think they do)
    • splitting things in layers (DB access, Data manipulation, and Data presentation) will also help working in team ; for instance, your HTML designer will only have to modify the presentation layer, and never have to touch to the others -- that's a plus !
  • Knowing MVC frameworks like those is nice for your resume (but that will only concern you if you're planning on doing this professionnaly) -- at least, it does in France, where I'm from.
Pascal MARTIN
And, if you are only building a community site (kinda skipped that, at first ^^ ), you should have a look at existing CMSes, which will do most of the work for you -- it'll let you plenty of time to do other stuff, which is never bad either ^^
Pascal MARTIN
+2  A: 

Why would you want to do all the work? Why don't you try and build something on existing and proved technology, like Drupal for instance, or Community Server?

Heck you could even use the StackExchange engine for that, although that's not a free one ;-)

fretje
Drupal's not the answer for everything, but it is great for community stuff if you add on certain modules that steer it towards a community. Blogs and a halfway decent forum come straight out of the box and you can customize it for anything else you'd need.
McAden
+1  A: 

Hey, my friends and I have been running a website for gamers since 2005 and I'm the "developer" of most of the stuff that runs on it. We use PHP/MySQL an I've developed everything from scratch.

Where to start is easy, just take your time and think about the concept of what you want to display. Then make a rough template of what the actual HTML/CSS page design should look like.

Then add the dynamic features like PHP coding and SQL queries etc. but separate the presentation (HTML) from the logic (PHP/MySQL) - you can do this buy using INCLUDE or REQUIRE_ONCE statements.

I prefer to do all the logic on top and only display variables in the HTML, e.g. a typical page would look like this:

<?php
     require_once('/system/standard.php');   // constants, functions, session etc.
     require_once('/system/database.php');   // database functionality etc.
     require_once('/system/authentication.php');   // security, logon etc.

     // do some logic e.g. database queries or some calculations.
     $data['username'] = 'Przystojny';
?>
<HTML>
...
Hello <?php print($data['username']); ?>
...
</HTML>
capfu
A: 

I would suggest you write a lightweight template system or use one from PHPClasses to handle the legwork of generating the pages. This one you can have modules which create the content and just 'slot' into the relevant placeholder. The Smarty template engine may be worth a look.

A sample of how it would look like:

<html>
<header>
 <title><!-- title_placeholder --></title>
 <script><!-- scripts_placeholder --></script>
</header>

<body>

  <div id='leftbar'>

    <!-- placeholder_1 -->
    <!-- placeholder_2 -->

  </div>

  <div id='main'>

    <!-- main_content -->

  </div>

 </body>

And the PHP is as simple as:

$loginSideBarModule = new LoginModule();
$template->replaceTag("placeholder_1", $loginSideBarModule->render());

There are many templating system on PHPClasses if Smarty is too heavy for you.

Extrakun
A: 

use buddypress bro