> -----Original Message-----
> From: Simon Dániel [mailto:simondan...@gmail.com]
> Sent: 12 July 2012 21:21
> To: php-general@lists.php.net
> Subject: [PHP] Entry point of an MVC framework
> 
> 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.
> 
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php

Hi Simon,

You'll probably want to look at Bootstrapping your framework too. Ideally the 
bootstrap will include (or have an autoload function) to load your classes - 
controllers/models/views, and it'll also deal with routing so deciding which 
controller and action to call based on the URL, this usually involves doing an 
explode() on the $_SERVER['QUERY_STRING'], and using Apache's mod_rewrite to 
forward all requests to your bootstrap (often named index.php)

Building frameworks and going through the motions are a great way to build up 
experience and play with areas of the language you might not normally use, you 
might want to get inventive with the Reflection class to check actions or 
controllers exist and then forward the user to a 404 page later on.

Cheers
Adam.

=============================================================================

This email is intended solely for the recipient and is confidential and not for 
third party unauthorised distribution. If an addressing or transmission error 
has misdirected this email, please notify the author by replying to this email 
or notifying the system manager (online.secur...@hl.co.uk).  If you are not the 
intended recipient you must not disclose, distribute, copy, print or rely on 
this email. 

Any opinions expressed in this document are those of the author and do not 
necessarily reflect the opinions of Hargreaves Lansdown. In addition, staff are 
not authorised to enter into any contract through email and therefore nothing 
contained herein should be construed as such. Hargreaves Lansdown makes no 
warranty as to the accuracy or completeness of any information contained within 
this email. In particular, Hargreaves Lansdown does not accept responsibility 
for any changes made to this email after it was sent. 

Hargreaves Lansdown Asset Management Limited (Company Registration No 1896481), 
Hargreaves Lansdown Fund Managers Limited (No 2707155), Hargreaves Lansdown 
Pensions Direct Limited (No 3509545) and Hargreaves Lansdown Stockbrokers 
Limited (No 1822701) are authorised and regulated by the Financial Services 
Authority and registered in England and Wales. The registered office for all 
companies is One College Square South, Anchor Road, Bristol, BS1 5HL. 
Telephone: 0117 988 9880

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Reply via email to