PHP: personal structure

I am going to write a framework for my web projects in PHP. Please do not tell me to use some existing frameworks (Cake, CodeIgniter, Symfony, etc.). I already looked at them and decided to write one for myself.

The structure itself will consist mainly of a modular system, a database handler and a template parser. (And much more, of course)

With a modular system, I mean that each module has exactly one PHP file and one or more templates associated with it. An example module will be modules/login.php, which uses templates/login.tplfor its design.

These days everyone (?) Is talking about the MVC (Model View Controller) concept, and most existing frameworks also use it.

So my questions are:

  • Is MVC effective for a personal structure?
  • Would it be a bad idea to use a modular system?
  • Have you ever written a framework for yourself? What are your experiences?
+5
source share
8 answers

Is MVC effective for a personal structure?

Yes it can be. Although, it can be a little too much (which is not necessarily bad if you are trying to learn)

Would it be a bad idea to use a modular system?

This is never a bad idea.

Have you ever written a framework for yourself? What are your impressions?

I wrote a common security framework for my group PHP applications when I was an intern. I learned a lot, but the project as a whole could benefit more from a pre-built solution.

, , . , . - - .

+7

MVC ?

MVC, - , -, . , , , MVC .

, , , . , .

, MVC, . . . , , . - . , PHP, , , . .

?

MVC -, , , . , , . : . , , , , , . , , , .

, . , , . , . , , .

- ? ?

, -. , , , . . , - , , , , .

, , . . , , , . , , - , . , , , , . : , , ; , , ; , ; , ; XXY . , .

, , , , . , , , . , , , . - . , , , , , . - . , , , .

, , . .

+2

PHP- . , .

, , mvc. . . , . , , . - .

, , . , . , .

, . . , , .

+1
  • MVC ?
  • ?

, . MVC - , , . . , php-, html, . , - . "". , .

, .

  • - ? ?

. , . . , . , . , .

(0x912abe25...):

.

. , . . , , -, , . , . , , .

,

      include_once('...page file ...');

, php . . , :

      function processCredentials()
      { 
           if (credentialsFail)
           {
                 include_once('loginpage.php');
           }
      }

, , , , . , - , (, master index.php - ). , , .

OO.

. - , .

SQL. , . . .

+1

, MVC , , , login.php ( ), ( ). , . class.login.php __autoload(), MVC.

0

PHP, MVC.

DAO, . daoFactory, DAO ( , log4php).

DAO (mysql), . Doug T. , , : ( ..), ORM, . , , mysql ( postgress), ( , ).

, Slim php restfull api: , json. smarty, , .

0

. , . , , - .

, , .

, - . - ? , . , , PHP-. , , , .

, . , , . , - ( API). .

.

-1
  • MVC
  • ""; , ( templates - )

re 1: . Allen Holub Holub on Patterns. : MVC - .

Tell Do not Ask - , , . , , , - . , , , , (!), .

, , - Injection Dependency:

interface Display
{
    function display($t, array $args);
}

class SomePartOfModel
...
{
    function output(Display $d)
    {
        $d->display('specific.tpl', array(
            'foo' => $this->whatever,
            ...
        ));
    }
}

OTOH, , - , . , : , , , PHP.

, SQL - . - DSL? , ORM. , . ORM. , - , , , , ...

, , , . , . , .

- , . , - : , , , , , ( csv ..), , .

re 2: it is certainly good to have a single structure. what you do not want to do is block yourself in a situation where the module cannot use more than one file.

Patterns

must be stored next to code that uses them for the same reason that code that works together must be stored together. Templates are a form of code, V in MVC. you will need fine-grained patterns that allow (re) use. there is no reason why the presentation layer should not be as DRY as other parts of the code.

-eleven
source

All Articles