On Thu, Jul 12, 2012 at 10:21:21PM +0200, Simon Dániel wrote:

> Hi,
> I have started to develop a simple MVC framework.
> I have a base controller class which is abstract and all of the
> controllers are inherited from that. Every controller contains actions
> represented by methods. (E. g. there is a controller for managing
> product items in a webshop, and there are seperate actions for create,
> modify, remove, etc.) There is also a default action (usually an index
> page), which is used when nothing is requested.
> But what is the best way to invoke an action? I can't do it with the
> baseController constructor, becouse parent class can't see inherited
> classes. And I can't do it with the constructor of the inherited
> class, becouse this way I would overwrite the parent constructor. And
> as far as I know, it is not a good practice to call a method outside
> of the class, becouse the concept of operation of the class should be
> hidden from the other parts of the application.

While I have a progressively growing dislike of frameworks, I'll give
you the following advice from what I've observed in other frameworks:

Normally, you build a controller class elsewhere which inherits from the
base controller class. Let's say it's a controller for blog entries.
Now, you populate the (child) controller with the methods you'll need
for each action. Like a method to delete blog entries. A method for
adding blog entries. Etc.

At that point, you have to decide if you're going to use server
redirection or standard URLs to get to your controller. That is:




The latter method is preferred by those who believe there's such a
mythical beast as "pretty URLs" preferred by search engines (there
isn't). It requires the use of .htaccess files and Apache's mod_rewrite,
which you may not have in a shared hosting environment.

Hopefully that helps.


Paul M. Foster

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to