SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 61
  1. #26
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when we use
    Code:
    modules/
        home/
            controllers/
            models/
            views/
        contact-us/
            controllers/
            models/
            views/
    how we can manage multy template that user/admin will select it ?

  2. #27
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    I'm quite surprised that you built your framework using this approach, that's great! Are you using your own core classes or you built your framework on top of another one?
    I built the framework like this for the very reason that it be different. Although there are many different frameworks, most are built the same way. The goal of this framework from the beginning was to be different by focusing on a fully modular architecture (which is why I found your thread and clicked on it!), so that any portion of the framework can be replicated by simply dragging and dropping a single folder. That is to say, that all the different components must be fully self-contained in a single folder (though they can depend on other components if required) to maximize portability.

    This framework started as really more of a learning experience than anything else, so I decided to build from scratch, drawing ideas from other existing frameworks to solve similar problems (Though when I started this framework, Zend, Symphony, and other popular frameworks were not yet finished or even considered "stable").

    I was still in college when I developed the initial base code, and didn't have a lot of time to setup and work on websites. The idea was to create a base set of modules and then copy them into multiple instances as quickly and easily as possible so I only had to focus on design instead of essentially re-creating the wheel every time like I had been doing. And as life turn out, I'm still working on improving the base code and building the framework rather than selling more websites and getting rich .

  3. #28
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bakhanbeigi View Post
    when we use
    Code:
    modules/
        home/
            controllers/
            models/
            views/
        contact-us/
            controllers/
            models/
            views/
    how we can manage multy template that user/admin will select it ?
    This is a problem I came up against, and the simple solution was to have a second parameter to the view-choosing function. If left blank (NULL), it would look for views in the current active component (itself). If a second parameter is specified, it will be the component name, and the view finder will look there for it.

    So:

    $this->view->setView('edit');

    Also allows a second optional parameter to specify the component name:

    $this->view->setView('edit', 'news');

  4. #29
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post

    Code:
    modules/
        home/
            controllers/
            models/
            views/
        contact-us/
            controllers/
            models/
            views/
    Take a look here. It has exactly the module structure you described but the difference is in the definition of what a module should do.
    http://www.open-publisher.net
    Last edited by atu; Sep 19, 2007 at 01:14.

  5. #30
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Czaries View Post
    And as life turn out, I'm still working on improving the base code and building the framework rather than selling more websites and getting rich
    Haha Yes, I know exactly what you mean. I'm starting to believe that spaghetti code is the secret to success, you don't get obsessed with programming paradigms and the only pattern you need to worry about is the colour pattern.

    Quote Originally Posted by atu View Post
    Take a look here. It has exactly the module structure you described but the difference is in the definition of what a module should do.
    http://www.open-publisher.net
    Great, thanks for the link! Yes, the concept is similar. I don't know why they are using the JAPA framework though, I would prefer to have Zend on a lower level.

    I've just realized that Wikipedia is mixing some concepts. It's comparing an object with a module. This is nonsense. In OOP, a module groups objects. Acording to Wikipedia, a module is pure procedural, and an object pure OO. How crazy is that?

  6. #31
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    I've just realized that Wikipedia is mixing some concepts. It's comparing an object with a module. This is nonsense. In OOP, a module groups objects. Acording to Wikipedia, a module is pure procedural, and an object pure OO. How crazy is that?
    I take it you've never programmed in pascal or any other language that supports modules? Wikipedia is correct, in as much as it's talking about modules as a language feature. What you guys are talking about is modular design, which is not the same thing as modular programming.

  7. #32
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pascal is a purely procedural language and has nothing to do with modules, maybe you heard something about Turbo Pascal. Anyway, neither Pascal, Turbo Pascal nor Delphi provides a nested module concept, or flat/vertical module structures. Believe me, I’m a Delphi programmer :P

    Also, you are talking about programming languages, we are talking about programming paradigms (styles). There are 2 completely different things.

    You are mixing programming paradigms (such as Object-oriented programming and modular programming) with programming languages (such as Pascal and Java).

    Anyway, I think that Pascal is out of the equation when it comes to Web development. We can't go that road. This is the Web, and we are the ones leading the way, so it's up to us to come up with new ideas and new concepts. I'm sure Pascal had his own definition of a module 350 years ago

    So, who ever wrote "a module is pure procedural, and an object pure OO", is wrong.

    [edit] Joined both posts
    Last edited by phpimpact; Sep 19, 2007 at 14:57.

  8. #33
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    You've just stumbled across the last object Pascal developer alive!

    You are getting it all wrong. Pascal is a purely procedural language and has nothing to do with modules, maybe you heard something about Turbo Pascal. Anyway, neither Pascal, Turbo Pascal nor Delphi provides a nested module concept, or flat/vertical module structures. Believe me, I’m a Delphi programmer :P
    I'm talking about extended pascal; delphi is a completely different branch of borland's own creation, and isn't an official standard, and neither is turbo pascal.

    Quote Originally Posted by phpimpact View Post
    Also, you are talking about programming languages, we are talking about programming paradigms (styles). There are 2 completely different things.
    No, I'm talking about language features, as is the wikipedia article that you're claiming is wrong. Certain languages have a feature called modules, which are used in modular programming, and yes, they are similar to classes but more procedural.


    Quote Originally Posted by phpimpact View Post
    You are mixing programming paradigms, such as Object-oriented programming and modular programming with programming languages, such as Pascal and Java.

    One thing has nothing to do with the other. I think you got confused with programming paradigm and you thought it was the same as a programming language. They are different things, programming languages are for example, Perl or PHP (interpretation languages), C++ (compilation languages) and Java (both). The you have programming paradigms (different programming styles), such as Object-oriented programming, modular programming, etc.

    Hope this helps
    edit: I'm not going to bother responding to this

  9. #34
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees View Post
    I'm talking about extended pascal; delphi is a completely different branch of borland's own creation, and isn't an official standard, and neither is turbo pascal.
    Ok, but I don't see the relation between pascal and modular programming. And pascal with the web...? Doesn't make any sense.

    We agree that a module can have functions or classes right? So why is a module procedural then?

  10. #35
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees View Post
    No, I'm talking about language features
    That's the problem I think. Here we are talking about php and modular programming

  11. #36
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol... Does it really matter what it's called when it obviously depends on the specific language in context? Let's not hijack this thread to create another meaningless internet argument, mmmk?

  12. #37
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    That's the problem I think. Here we are talking about php and modular programming
    I was simply explaining why your comment about wikipedia being wrong was itself wrong; The article is about the language feature, and not what you guys are discussing.

  13. #38
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, one of the ideas behind this thread is to find out what other people think and know about modules and how they would implement them in a modular architecture. So any comment is more than welcome.

    Ok, 33d, I think I was talking about tomatoes, you were talking about potatoes. But, it's funny that whoever wrote that in Wikipedia, was talking about programming paradigms and not programming languages:

    This article is about the computer programming paradigm.
    ...
    Procedural programming is sometimes used as a synonym for imperative programming (specifying the steps the program must take to reach the desired state), but can also refer (as in this article) to a programming paradigm based upon the concept of the procedure call.
    ...
    The focus of procedural programming is to break down a programming task into a collection of data structures and subroutines, whereas in object oriented programming it is to break down a programming task into objects.
    Code:
    pure OO     |  pure procedural
    ------------|-------------------
    methods     | functions
    objects     | modules
    message     | call
    member      | variable
    So, what someone is basically saying is: When you think of an object, think of OO. When you think of a module, think of procedural.

    Programmers tend to group files and folders and put them in a directory called "modules". For example: Someone might have 3 PHP files. Each file is located in a folder, which is located in the modules/ directory. So, do we have 3 modules?

    A programmer:

    Pure procedural: Yes, you can group files into modules.
    Object-oriented: Yes.

    An architect:

    Pure procedural: No, it doesn't provide a nested module concept, polymorphism and/or vertical module structures.
    Object-oriented: Yes.

    So, my question is, is it wrong to associate modules with procedural? I think it is, but that's my opinion of course.

    Here is the link where I found this: Procedural programming

    Cheers, and thanks for sharing your thoughts on this

  14. #39
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Today, talking about this with a colleague, he suggested adding a new element to the module: An API controller:

    Code:
    modules/
        contact-us/
            controllers/
                ContactUs.php
                ContactUsBackend.php
                ContactUsAjax.php
                ContactUsApi.php
            models/
                ContactUsModel.php
            views/
                index.html
            install/
                ContactUsInstall.php
    Very interesting. So now, the module has 4 action controllers:

    Front-end action controller:
    ContactUs: Returns a template object to the front controller.

    Back-end action controller:
    ContactUsBackend: Returns a template object to the front controller.

    Ajax action controller:
    ContactUsAjax: Outputs a string (html)

    API action controller:
    ContactUsApi: Outputs a string (xml).

    Example: Server request
    PHP Code:
    $this->apiController('contact-us')->request('action''param1''param2'); 
    Example: HTTP request
    Code:
    http://www.example.com/api/contact-us/action/param1/param2
    The thing is, API URI's don't need to be search engine friendly right? Users are never going to see them, only developers. So we can have something like this instead:

    Example: HTTP request
    Code:
    http://www.example.com/api/?module=contact-us&action=get-location&key1=param1&key2=param2
    These are just some ideas....

  15. #40
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Front-end action controller:
    ContactUs: Returns a template object to the front controller.
    This is the base component (module) controller

    Back-end action controller:
    ContactUsBackend: Returns a template object to the front controller.
    I don't use whole separate controller, I just use grained permission levels on the front end controller to control access to admin functions. There are default permssions based on naming conventions (create, edit, save, etc.) and are also editable/changeable with an array class variable to create controller-specific rules.

    Ajax action controller:
    ContactUsAjax: Outputs a string (html)
    My request object has a method that I use - if($request->isXmlHttpRequest()) to determine if the request has been sent with an Ajax call. If so, I either choose a different template to render and set the layout to 'false' (no layout will wrap around the content), or simply echo out the contents within the function itself (If I'm in a hurry). I don't have a separate object for this.

    API action controller:
    ContactUsApi: Outputs a string (xml).
    This one could be useful, because an API would be very different from the rest of your app that basically just gets data for itself. I would definately use query strings for APIs, because when programming GET or POST calls (like through cURL, Sockets, and other libraries) you have to build a query string anyways. I would probably use the standard URLs up until the special variables. You have:
    Code:
    http://www.example.com/api/?module=contact-us&action=get-location&key1=param1&key2=param2
    I would probably do something like this instead:
    Code:
    http://www.example.com/api/contact-us/action/?key1=param1&key2=param2
    That way you can keep the default controller/action mappings in place and just use the query string to pass extra request parameters.

  16. #41
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    Well, one of the ideas behind this thread is to find out what other people think and know about modules and how they would implement them in a modular architecture. So any comment is more than welcome.

    Ok, 33d, I think I was talking about tomatoes, you were talking about potatoes. But, it's funny that whoever wrote that in Wikipedia, was talking about programming paradigms and not programming languages:
    I think the wikipedia article is somewhat ambiguous. The word "module" has multiple meanings, and they should have made a better effort to define the way they're using the term before they used it.


    Quote Originally Posted by phpimpact View Post
    Code:
    pure OO     |  pure procedural
    ------------|-------------------
    methods     | functions
    objects     | modules
    message     | call
    member      | variable
    So, what someone is basically saying is: When you think of an object, think of OO. When you think of a module, think of procedural.
    No, what they're saying is that modules (and by that I mean the language feature) in procedural languages serve the same purpose that objects do in OO languages. They are a way of grouping functions, variables and/or constants into a namespace, often with visibility modifiers. Think of them like a class that only has static methods.

    Quote Originally Posted by phpimpact View Post
    Programmers tend to group files and folders and put them in a directory called "modules". For example: Someone might have 3 PHP files. Each file is located in a folder, which is located in the modules/ directory. So, do we have 3 modules?
    Well, people who program in a language that doesn't support modules might do that; someone who programs in a language like Ruby (that does support modules) would use a different term, since the word module has a very specific meaning, just like the word class. Often the word "component" is used instead.

    Quote Originally Posted by phpimpact View Post
    A programmer:

    Pure procedural: Yes, you can group files into modules.
    Object-oriented: Yes.

    An architect:

    Pure procedural: No, it doesn't provide a nested module concept, polymorphism and/or vertical module structures.
    Object-oriented: Yes.

    So, my question is, is it wrong to associate modules with procedural? I think it is, but that's my opinion of course.
    Again, that depends on which meaning of the word module you're using. Modules (the language feature) are mostly found in procedural language, where they are used like objects are used in OO languages. So yes, if you're talking about the language feature, modules are general associated with procedural languages. However, there are some OO languages that also feature modules but that's another story.

  17. #42
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mate, I'm talking about PHP, unless I posted this message in the wrong section of the forum :P

    I'm clearly talking about modular programming and object-oriented programming.

  18. #43
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A way i have seen on a CMS for company that i worked for was to do it like this.. and then have a template directory, and put in there:

    template/modules/contact/ <-- views (templates) go here

    And then it overrides the default ones.

    Also btw i see that the zendframework makes this possible too:
    http://framework.zend.com/manual/en/...r.modular.html

    Quote Originally Posted by bakhanbeigi View Post
    when we use
    Code:
    modules/
        home/
            controllers/
            models/
            views/
        contact-us/
            controllers/
            models/
            views/
    how we can manage multy template that user/admin will select it ?
    Go visit my site :-D you know you want to ;-)
    www.mech7.net

  19. #44
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Czaries View Post
    I don't use whole separate controller, I just use grained permission levels on the front end controller to control access to admin functions. There are default permssions based on naming conventions (create, edit, save, etc.) and are also editable/changeable with an array class variable to create controller-specific rules.
    I'm with you. So a permission maps to a method in your base component controller (action controller)? If I'm not wrong, you add a method to your controller and then the name of the rule to the array?

    Quote Originally Posted by Czaries View Post
    I would probably do something like this instead:
    Code:
    http://www.example.com/api/contact-us/action/?key1=param1&key2=param2
    That way you can keep the default controller/action mappings in place and just use the query string to pass extra request parameters.
    Yes, makes more sense. Thanks

  20. #45
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    Mate, I'm talking about PHP, unless I posted this message in the wrong section of the forum :P

    I'm clearly talking about modular programming and object-oriented programming.
    No, you're talking about wikipedia articles that have nothing to do with PHP, insisting that you disagree with them, without realising that they're not talking about the same thing you are!

  21. #46
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees View Post
    No, you're talking about wikipedia articles that have nothing to do with PHP, insisting that you disagree with them, without realising that they're not talking about the same thing you are!
    Ohhh come one. It was an off-topic about an article, no big deal. You don;t need to be so negative, we are here to share opinions, not to see who's right or wrong

  22. #47
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    Ohhh come one. It was an off-topic about an article, no big deal. You don;t need to be so negative, we are here to share opinions, not to see who's right or wrong
    You bring up off-topic subjects, and then you tell me I'm being off topic. How do you expect me to respond to that? In any case, I'm going to drop the subject, as I don't think I can explain myself more clearly than I already have.

  23. #48
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pixelsoul View Post
    Also btw i see that the zendframework makes this possible too:
    http://framework.zend.com/manual/en/...r.modular.html
    This is a good example as well. That's what I like about Zend, they are always open to new suggestions and ideas. The title says a lot about their modular implementation: "Using a Conventional Modular Directory Structure". For now, they are focusing more on the directory structure, but that's a good start:

    Quote Originally Posted by Zend
    The Conventional Modular directory structure allows you to separate different MVC applications into self-contained units.
    This is the first step to modular programming. And I'm sure that this implementation will inspire other developers to come up with more ideas. Zend is talking about self-contained units, and that's important, but when it comes to web development we need to contain more (css, js, images, etc).

    This paradigm offers much more advantages than just re-organizing the directory structure. It works fine in flat structures, but what about vertical structures? When you need to nest modules, inherit code or configuration files from parent modules?

    Code:
    http://www.example.com/<parant_module>/<child_module>/action
    I'm sure I'm not the only one doing that. Then, for example, when I'm working on e-commerce sites, some modules they get bigger and bigger, and so does the action controller. So, what if we have a router that not only maps actions to methods, but also actions to files? That way we can distribute code inside the module.

    I think that OOP and MP together, is very powerful.

  24. #49
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    I'm with you. So a permission maps to a method in your base component controller (action controller)? If I'm not wrong, you add a method to your controller and then the name of the rule to the array?
    Yes, that's pretty much exactly how I do it - If I deviate from the standard set of commonly named functions (which I have to in some cases), then I must make sure to write a custom access rule for it based on the permission role. It is more or less like:

    'public' => array('index', 'view')
    'admin' => array('create', 'edit', 'save')

    etc...

  25. #50
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phpimpact View Post
    This paradigm offers much more advantages than just re-organizing the directory structure. It works fine in flat structures, but what about vertical structures? When you need to nest modules, inherit code or configuration files from parent modules?

    Code:
    http://www.example.com/<parant_module>/<child_module>/action
    I'm sure I'm not the only one doing that. Then, for example, when I'm working on e-commerce sites, some modules they get bigger and bigger, and so does the action controller. So, what if we have a router that not only maps actions to methods, but also actions to files? That way we can distribute code inside the module.

    I think that OOP and MP together, is very powerful.
    I recently (within the last month) had to deal with this very problem of nesting modules breaking the standard URL scheme, so I ended up creating a built-in way to signify a nested module so it can automatically get mapped correctly without a custom routing rule. Here's what I came up with:

    Code:
    http://www.example.com/<parant_module>:<child_module>/action
    It's almost exactly like yours, except that there is a colon between the parent and child modules instead of a directory slash. As said above, this allows the framework to know just by the URL alone that it is accessing a nested module without another custom routing rule. It may not be the best way to do it, but it's working excellently for me so far.


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
  •