Best way to execute actions within a class

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

 



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.

Now that i have started executing constructors within the main page files, I
have come to think of better ways passing around a url possibly like
something like this

someurl/index/someproject_somesubproject/view

or

someurl/someproject_somesubproject/view

or

someurl/index/aliasofclass/view

or

someurl/aliasofclass/view

and for adding keys to the end for db stuff something like

someurl/index/aliasofclass/view?ID=1

or

someurl/index/aliasofclass/view/ID/1

i think then all u need is the main index.php file which works out which
class to load and execute ? And possibly peristist the objects loads too via
shm maybe ?

And if you need other files it could be like

someurl/otherfile/aliasofclass/view/ID/1

I'm sure this is all mod_rewrite stuff, is this taxing to do ?

Let me know always open to suggestions especially ways to do caching better.

-- 
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