Jump to content

Recommended Posts

I am interested in using the MVC approach for my application. I am not interested in using a existing framework, I feel that I'd have a better understanding if I was a part of the creations processes.

 

Anyway, how should I structure my file system? Is there a standard that should be followed, or does it matter as long as youre following an MVC practice?

 

Thanks

 

sorry if this has been asked before, didnt find anything with the search

Link to comment
https://forums.phpfreaks.com/topic/63447-mvc-file-structure/
Share on other sites

as with most things like this, i think it generally depends on how you like working and/or what you like about what you've already used.

for example - i found CodeIgniter easy to learn/use and had a bag of features, but CakePHP was more solid and consistent and did more for you - so when I made my own, I took the best from both of these and made something that i was comfortable working with.

 

so in answer to what you need to have when rolling your own, the question is somewhat easier to answer than "which is the best framework to use?" - simply because you can decide based on what you already know.

 

I'd definitely recommend having a good play with several frameworks/CMS's though - even if it's just a 10 minute mess around to see what first impressions/ease of use is like.

Link to comment
https://forums.phpfreaks.com/topic/63447-mvc-file-structure/#findComment-316190
Share on other sites

yeah, ill download them and play around with them for a little. I watched the codeignither tutorial on their site a while ago, ill look again.

 

Thanks for the insight.

 

I am currently thinking of something like this

 

www(public pages)

-js

-css

-ssa(server-side actions - ajax)

classes(this will contain the meat of the application)

 

I am just not sure how to structure that classes directory. Should I do model and controller directories for each section or have a base model directory and have it contain files for all sections of the application? (i've seen it done both ways)

 

But I will continue looking aorund.

Link to comment
https://forums.phpfreaks.com/topic/63447-mvc-file-structure/#findComment-316195
Share on other sites

yeah, ill download them and play around with them for a little. I watched the codeignither tutorial on their site a while ago, ill look again.

 

Thanks for the insight.

 

I am currently thinking of something like this

 

www(public pages)

-js

-css

-ssa(server-side actions - ajax)

classes(this will contain the meat of the application)

 

I am just not sure how to structure that classes directory. Should I do model and controller directories for each section or have a base model directory and have it contain files for all sections of the application? (i've seen it done both ways)

 

But I will continue looking aorund.

File structure really doesn't matter at all. Do what you are most comfortable using. I prefer separation of directories, so I do mine that way, but you might like to have them in one folder, which you can do. Some things can be stuck in one directory and have an indicator appended to the filename, ie: some.model.php. Just go with what works for you.
Link to comment
https://forums.phpfreaks.com/topic/63447-mvc-file-structure/#findComment-316204
Share on other sites

For convenience (I'm the biggest advocate of convenience you'll ever find):

 

<?php
function __autoload($className){
	include str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
}
?>

 

It's common practice to lowercase packages and subpackages, but I prefer UpperCamelCase for class names. E.g.:

 

Backbone_Controller_Token

 

Library
|___Backbone
      |____Controller
             |____Token.php

Link to comment
https://forums.phpfreaks.com/topic/63447-mvc-file-structure/#findComment-316536
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.