Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much directory separation should my framework have?

I've been trying a bunch of different directory structures for my PHP MVC framework. While doing this, I thought of a few reasons to separate different parts of the application from each other.

For instance, let's say this is my current structure:

- index.php
- private/
    - application/
        - ... (MVC stuff. Irrelevant I think...)
    - config/
        - config.php
    - framework/
        - bootstrap.php
        - includes/
        - library/
            - ... (Framework classes)
    - libraries/
        - Zend/
        - PEAR/
 - public/
     - css/
     - images/

The way I have it, I can update the framework simply by overwriting the /private/framework/ directory, which won't affect the user's framework configuration in /private/config/, or the 3rd party libraries in /private/libraries/.

The /index.php file is used almost purely to load the /private/framework/bootstrap.php file, which will mean updating the /private/framework/ directory will also update the main bootstrapping file (Saving me from having to update the /index.php file, which will stay as is, as there's not much at all in it).

Also, the application is separate from everything to do with the framework too, so the user can switch/change/update their applications when needed without having to worry about other directories.

Am I on the right track here with regards to separating the directories from one another to make them easier to update?

I've seen in some frameworks that they have both their /private/libraries/ and /private/application/ directories inside their framework directory... but this seems to me like it would be hard to update to a newer version of the framework if needed. Or am I thinking about it the wrong way?

You can see my previous dir structure here if you're interested. My new one is a little different (hopefully better...), as is my question, so I thought it warranted the posting of a new question.

It's not as small of a question as I would have hoped, but ah well! ;)

Thanks in advance =)

like image 488
manbeardpig Avatar asked Jul 05 '10 18:07

manbeardpig


1 Answers

I would suggest separating framework code from application code. The framework should be under one top-level directory and the application under a different one.

Actually... I suggest you look at the directory structure used by CakePHP.

like image 142
Kalium Avatar answered Sep 21 '22 11:09

Kalium