SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    modular design considerations

    well, i just want to know does anyone know or had experience with making modular php based framewok. For example that i have modules (menu, authorisation,news etc.) and that i can load this modules automatically.

    i read all the post here concernig this theme, and i read a lot about design patterns... i have picture in my mind of how stuff would look like, but i have one problem.

    how to completely distinct layers in my modular apprach. for example i dont want my news module to know about existance of authorisation layer, but without that i find implemeting protection layer much harder.

    does anybody know where to find tutorials on this modules separation, or they allways have to have some level of knowing what another module have to do?

    sorry for my engl...

  2. #2
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way I've gone about doing what you described is by using a combination of 'filters', 'views', and 'commands'. In my framework, a filter has a preProcess() and postProcess() method, as well as a filter() method. The filter() method is declared final in the parent class and looks something like this:

    PHP Code:
    public final filter$request )
    {
      
    $this->preProcess$request );
      if( 
    $this->nextFilter )
        
    $this->nextFilter->filter$request );
      
    $this->postProcess$request );

    This allows me to chain filters together. These filters can remain relatively independent of one another. At the end of the filter chain I have a 'command' object, which is invoked by my controller. The controller implements the filter interface so that it is called by the last filter in the chain -- thus, it invokes the 'command' object after all of the filters have preProcess()'d the request, but before they have postProcess()'d. After the command invocation, the controller includes a view file, which generally prints some output to the screen which the filters can postProcess() if they need to.

    Hopefully all that made some sense . I suggest you look up the Front Controller pattern, as well as the Intercepting Filter pattern. They are the two patterns I implement in my framework.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •