Re: Best way to execute actions within a class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* daniel@xxxxxxxxxxxxxxxx <daniel@xxxxxxxxxxxxxxxx>:
> I have been building a lightweight PHP4 based, hopefully PHP5 OO structure
> where each page or php file contains its own class which is then executed
> using the constructor like so
>
> new SomeProject_SomeSubProject();
>
>
> within the subclasses contructor I then call a method called start which is
> in a base class called Page which is extended from the main project class
> called SomeProject.
>
> Within start it calls a method to check action page get uri's ie
> ?action=view , what i used to within procedural code is use switch
> statements but seem taxing. Within this now will check if its a get or post
> method and execute a method in the class with the same name ie public
> function action_view() or if its a post method i have chosen to call it
> post_action_view(). Now is this a good setup I would like some feedback on
> how people in an OO world would achieve this.

Okay, let's go into <self_promotion_mode>:

This sounds exactly like how Cgiapp works, a class I ported from perl,
and available at:

    http://freshmeat.net/projects/cgiapp/

Cgiapp is basically a do-nothing class that makes creating application
classes that work similar to how you describe very simple to code. Such
applications are then trivially re-usable, extensible, and customizable
(through instance scripts). And it provides all this in a mere
few-hundred lines of code.

I bring it up because you asked (a) if your setup is a good setup
(probably), and (b) how people in an OO world would achieve this
(Cgiapp).

You might check out the code and the docs to see if you can glean some
ideas for your projects.

</self_promotion_mode>

(Man, I hate doing that... buy I *am* proud of that bit o' code, even if
it isn't completely original.)

-- 
Matthew Weier O'Phinney           | mailto:matthew@xxxxxxxxxx
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux