Jump to content

Getting started with MVC


stuffradio

Recommended Posts

I'd like to start using the MVC pattern and try to understand it fully. I do understand the concept... but I'm trying to grasp how I would put that down in code.

 

I want to make my framework modular, so this is an idea on how I'm going to lay it out.

 

Folders = --

Files = -

 

-- config

  - config for the system

 

-- docs

  -doc files

 

-- images

  -- image stuff here

 

-- modules

  -- module name

      - module files

 

-- pages

  - page1.php

  - page2.php

 

- index.php

etc.

 

Do you have any ideas on how I should start working out the bare bones of the structure?

Link to comment
Share on other sites

I started on the same endeavor this week. In fact, I already mentioned throwing up the code for another guy on the forums.

 

Right now it's about as bare bones as it gets. The core is functional, but I do have a couple more things I want to add before I call it complete. Anyway, here's how I went about it:

 

base - this is the base system that includes my code

    Libraries - class files used to build the base

          Loader.php - invokes the system and stores objects in a cache so that 1 instance can be shared

          Router.php - responsible for sending and receiving requests between model, view, controller

          Template.php - class used for generating the views (templates) and caching

          URI.php - class used for parsing/storing the URI requests that come in

 

cache - cached files generated by the view get stored here

 

ext - this is the extension of the base... actual user contributed code goes here

    Controllers - this is where controllers go

    Models - this is where models go

    Views - this is where views go

 

I've got a few more files laying around, but the above is what does the majority of the work. Like I said, I've got a few more things I want to do (mainly documentation) then I'll throw up the code and you're welcome to do whatever you want with it. I'll then wait eagerly for comments... and of course criticism on how I've developed things :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.