From: Dan L. <da...@we...> - 2003-03-14 11:49:22
|
In an earlier post I read in the archives, Arnold mentioned possibly utilizing the digester from php.MVC. I think using digester would be a good thing, though the code from that project is rather poor, so I ported it myself (based on the digester distributed with struts-1.0.2). Hopefully, when I free up some more time, I'll bring it up to speed with the latest release (commons-digester-1.4.1, I believe). I haven't fully tested it yet, but so far so good. http://webweaver.org/dan/php/digester/W2C_XML_Digester-1.0b.tgz -- Dan Loda <da...@we...> webweaver.collective |
From: Tony B. <to...@to...> - 2003-03-14 15:13:23
|
OK, call me the dummy, what does this digester stuff do. Admittedly I'm knew to struts and relatively so to MVC. --Tony On 14 Mar 2003, Dan Loda wrote: > In an earlier post I read in the archives, Arnold mentioned possibly > utilizing the digester from php.MVC. I think using digester would be a > good thing, though the code from that project is rather poor, so I > ported it myself (based on the digester distributed with struts-1.0.2). > > Hopefully, when I free up some more time, I'll bring it up to speed with > the latest release (commons-digester-1.4.1, I believe). > > I haven't fully tested it yet, but so far so good. > > http://webweaver.org/dan/php/digester/W2C_XML_Digester-1.0b.tgz > > -- Tony Bibbs "I guess you have to remember that those who don't to...@to... hunt or fish often see those of us who do as harmlessly strange and sort of amusing. When you think about it, that might be a fair assessment." --Unknown |
From: Jason S. <jsw...@ya...> - 2003-03-14 15:32:25
|
I have not yet looked at the code, but I belive it is just the way to take an XML configuration file (for mappings, etc.) and transforming it into an array usable by the Phramework. I would like to keep this particular code (loading configurations) abstract enough in Phrame that you could choose to get your configuration and mappings from any source you choose: PHP script arrays, retrieved from a database or the XML configuration file. Phrame might "officially" support the XML version, but it would be nice to allow a developer to easily switch out to their configuration strategy of choice. My $0.02 :) Jason --- Tony Bibbs <to...@to...> wrote: > OK, call me the dummy, what does this digester stuff do. Admittedly I'm > knew to struts and relatively so to MVC. > > --Tony > > On 14 Mar 2003, Dan Loda wrote: > > > In an earlier post I read in the archives, Arnold mentioned possibly > > utilizing the digester from php.MVC. I think using digester would be a > > good thing, though the code from that project is rather poor, so I > > ported it myself (based on the digester distributed with struts-1.0.2). > > > > Hopefully, when I free up some more time, I'll bring it up to speed with > > the latest release (commons-digester-1.4.1, I believe). > > > > I haven't fully tested it yet, but so far so good. > > > > http://webweaver.org/dan/php/digester/W2C_XML_Digester-1.0b.tgz > > > > > > -- > Tony Bibbs "I guess you have to remember that those who don't > to...@to... hunt or fish often see those of us who do as > harmlessly strange and sort of amusing. When you > think about it, that might be a fair assessment." > --Unknown > > > > > ------------------------------------------------------- > This SF.net email is sponsored by:Crypto Challenge is now open! > Get cracking and register here for some mind boggling fun and > the chance of winning an Apple iPod: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > _______________________________________________ > Phrame-devel mailing list > Phr...@li... > https://lists.sourceforge.net/lists/listinfo/phrame-devel __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |
From: Tony B. <to...@to...> - 2003-03-14 15:36:59
|
Ok, in that case is would seem you would need a simple configuration factory to create right object for accessing the configuration variables. --Tony On Fri, 14 Mar 2003, Jason Sweat wrote: > I have not yet looked at the code, but I belive it is just the way to take an > XML configuration file (for mappings, etc.) and transforming it into an array > usable by the Phramework. > > I would like to keep this particular code (loading configurations) abstract > enough in Phrame that you could choose to get your configuration and mappings > from any source you choose: PHP script arrays, retrieved from a database or the > XML configuration file. Phrame might "officially" support the XML version, but > it would be nice to allow a developer to easily switch out to their > configuration strategy of choice. > > My $0.02 :) > > Jason > > > --- Tony Bibbs <to...@to...> wrote: > > OK, call me the dummy, what does this digester stuff do. Admittedly I'm > > knew to struts and relatively so to MVC. > > > > --Tony > > > > On 14 Mar 2003, Dan Loda wrote: > > > > > In an earlier post I read in the archives, Arnold mentioned possibly > > > utilizing the digester from php.MVC. I think using digester would be a > > > good thing, though the code from that project is rather poor, so I > > > ported it myself (based on the digester distributed with struts-1.0.2). > > > > > > Hopefully, when I free up some more time, I'll bring it up to speed with > > > the latest release (commons-digester-1.4.1, I believe). > > > > > > I haven't fully tested it yet, but so far so good. > > > > > > http://webweaver.org/dan/php/digester/W2C_XML_Digester-1.0b.tgz > > > > > > > > > > -- > > Tony Bibbs "I guess you have to remember that those who don't > > to...@to... hunt or fish often see those of us who do as > > harmlessly strange and sort of amusing. When you > > think about it, that might be a fair assessment." > > --Unknown > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by:Crypto Challenge is now open! > > Get cracking and register here for some mind boggling fun and > > the chance of winning an Apple iPod: > > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > > _______________________________________________ > > Phrame-devel mailing list > > Phr...@li... > > https://lists.sourceforge.net/lists/listinfo/phrame-devel > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Web Hosting - establish your business online > http://webhosting.yahoo.com > -- Tony Bibbs "I guess you have to remember that those who don't to...@to... hunt or fish often see those of us who do as harmlessly strange and sort of amusing. When you think about it, that might be a fair assessment." --Unknown |
From: Arnold C. <arn...@ya...> - 2003-03-14 18:17:12
|
Here is a good article on the digester: http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html Arnold --- Tony Bibbs <to...@to...> wrote: > Ok, in that case is would seem you would need a > simple configuration > factory to create right object for accessing the > configuration variables. > > --Tony > > On Fri, 14 Mar 2003, Jason Sweat wrote: > > > I have not yet looked at the code, but I belive it > is just the way to take an > > XML configuration file (for mappings, etc.) and > transforming it into an array > > usable by the Phramework. > > > > I would like to keep this particular code (loading > configurations) abstract > > enough in Phrame that you could choose to get your > configuration and mappings > > from any source you choose: PHP script arrays, > retrieved from a database or the > > XML configuration file. Phrame might "officially" > support the XML version, but > > it would be nice to allow a developer to easily > switch out to their > > configuration strategy of choice. > > > > My $0.02 :) > > > > Jason > > > > > > --- Tony Bibbs <to...@to...> wrote: > > > OK, call me the dummy, what does this digester > stuff do. Admittedly I'm > > > knew to struts and relatively so to MVC. > > > > > > --Tony > > > > > > On 14 Mar 2003, Dan Loda wrote: > > > > > > > In an earlier post I read in the archives, > Arnold mentioned possibly > > > > utilizing the digester from php.MVC. I think > using digester would be a > > > > good thing, though the code from that project > is rather poor, so I > > > > ported it myself (based on the digester > distributed with struts-1.0.2). > > > > > > > > Hopefully, when I free up some more time, I'll > bring it up to speed with > > > > the latest release (commons-digester-1.4.1, I > believe). > > > > > > > > I haven't fully tested it yet, but so far so > good. > > > > > > > > > http://webweaver.org/dan/php/digester/W2C_XML_Digester-1.0b.tgz > > > > > > > > > > > > > > -- > > > Tony Bibbs "I guess you have to > remember that those who don't > > > to...@to... hunt or fish often see those > of us who do as > > > harmlessly strange and sort > of amusing. When you > > > think about it, that might > be a fair assessment." > > > --Unknown > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by:Crypto > Challenge is now open! > > > Get cracking and register here for some mind > boggling fun and > > > the chance of winning an Apple iPod: > > > > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > > > _______________________________________________ > > > Phrame-devel mailing list > > > Phr...@li... > > > > https://lists.sourceforge.net/lists/listinfo/phrame-devel > > > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Web Hosting - establish your business > online > > http://webhosting.yahoo.com > > > > -- > Tony Bibbs "I guess you have to remember > that those who don't > to...@to... hunt or fish often see those of > us who do as > harmlessly strange and sort of > amusing. When you > think about it, that might be a > fair assessment." > --Unknown > > > > > ------------------------------------------------------- > This SF.net email is sponsored by:Crypto Challenge > is now open! > Get cracking and register here for some mind > boggling fun and > the chance of winning an Apple iPod: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > _______________________________________________ > Phrame-devel mailing list > Phr...@li... > https://lists.sourceforge.net/lists/listinfo/phrame-devel __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |
From: Jason S. <jsw...@ya...> - 2003-03-15 05:58:28
|
Hello all, Had some time tonight to work with some ideas I have had recently. I wanted to modify Phrame to a) not have to include all the models/ actions/ forms/ and views/ directories (to improve application performance) b) create a view factory (each of my views is a separate class that has a Render method that accepts a smarty object) c) create a default action to be process if no other action was specified (in my case, ShowViewAction) Seems to be up and working. Here are some of the changes I have been working with: to ActionController.php: 134c134 < function _processMapping($mappings, $request) --- > function &_processMapping($mappings, $request) 138c138,143 < $actionMapping = $this->_actionMappings->get($name); --- > if ($this->_actionMappings->containsKey($name)) { > $actionMapping = $this->_actionMappings->get($name); > } else { > $name = $this->_options[_DEFAULT_ACTION]; > $actionMapping = $this->_actionMappings->get($name); > } 155c160 < function _processForm($mappings, $request) --- > function &_processForm($mappings, $request) 164a170,171 > //JES > require_once "forms/$type.php"; 189c196 < function _processValidate($actionMapping, $actionForm) --- > function _processValidate(&$actionMapping, &$actionForm) 210c217 < function _processAction($actionMapping, $actionForm) --- > function &_processAction(&$actionMapping, &$actionForm) 215a223,224 > //JES > require_once "actions/$type.php"; 236c245 < function _processForward($actionForward) --- > function _processForward(&$actionForward) 246a256 > exit; to Constants.php (changed the whole file to avoid E_ALL notices): <?php //request contant(s) define('_ACTION', 'action'); define('_VIEW', 'view'); //session constant(s) define('_CONTROLLER', '_controller'); define('_ERRORS', '_errors'); define('_FORM', '_form'); //mappings constant(s) define('_ACTION_FORMS', '_actionForms'); define('_ACTION_MAPPINGS', '_actionMappings'); define('_TYPE', '_type'); define('_NAME', '_name'); define('_INPUT', '_input'); define('_VALIDATE', '_validate'); define('_ACTION_FORWARDS', '_actionForwards'); define('_PATH', '_path'); define('_REDIRECT', '_redirect'); //options constant(s) define('_CACHE', '_cache'); define('_ERROR_REPORTING', '_errorReporting'); define('_ERROR_HANDLER', '_errorHandler'); //JES define('_DEFAULT_ACTION', '_defaultAction'); ?> to include.php: <?php require_once 'util/Object.php'; require_once 'util/ArrayList.php'; require_once 'util/HashMap.php'; require_once 'util/Stack.php'; require_once 'util/ListIterator.php'; //require_once 'ext/Xml.php'; require_once 'Constants.php'; require_once 'Action.php'; require_once 'ActionController.php'; require_once 'ActionForm.php'; require_once 'ActionForward.php'; require_once 'ActionMapping.php'; require_once 'MappingManager.php'; require_once 'ViewFactory.php'; ?> MappingManager.php was posted to the list earlier. The new ViewFactory.php is: <?php /** * view class directory */ define('PHRAME_VIEW_CLASS_DIR', 'views/'); /** * class to create Phrame Mapping arrays * * @author Jason E. Sweat * @since 2003-01-13 */ class ViewFactory extends Object { /** * constructor * * @return void */ function ViewFactory() { trigger_error("ViewFactory is a virtual class, please extend for your application"); return false; } /** * abstract function to return class based on view * * Must be overridden in the application, should always return a valid class file. * * @return void */ function _GetViewClass($psView) { $s_error = 'ViewFactory::_GetViewClass is a virtual method, please extend for your application'; trigger_error($s_error); die($s_error); } /** * factory function * * @return object the view object */ function &Build($psView) { $s_view_class = $this->_GetViewClass($psView); require_once PHRAME_VIEW_CLASS_DIR.$s_view_class.'.php'; $o_view = new $s_view_class; return $o_view; } } When defining the applicaiton options, I added ,_DEFAULT_ACTION => 'ShowView' and my ShowViewAction is: class ShowViewAction extends Action { /** * perform the action of showing a view * * @param object $poActionMapping the action mapping object * @param object $poActionForm the form object * @return object ActionForward */ function Perform(&$poActionMapping, &$poActionForm) { $o_view_factory = new SeiViewFactory; $o_view = $o_view_factory->Build($poActionForm->Get('view')); $o_smarty = new Smarty; //any default assignments //render the template $o_view->Render($o_smarty); //$o_action_forward = &$poActionMapping->Get('debug'); //return $o_action_forward; } I hope you find some of these changes of interest. Regards, Jason __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |
From: Tony B. <to...@to...> - 2003-03-20 00:14:16
|
Folks, I had the pleasure to pour through the Phrame code in painstaking detail trying to see how refactoring it might proceed. As I spent more and more time I found things in Phrame that simply didn't make sense to me. In the end, I took some of my wants and needs along with the good ideas from Phrame and did a ground-up MVC implementation. I hope this doesn't appear to be a slap in the face to anyone on this list and that a keen eye is given to my implementation for the differences. I look at what I have as a combination the good things in Phrame with a number of changes to reduce the payload and complexity. Ok, now for the notable differences: 1) config files has some basic configuration: - $configData[_DIRS][_MVC_BASE]: This is the location of the MVC codebase - $configData[_DIRS][_VIEWS]: Directory where views can be found - $configData[_DIRS][_MODELS]: Directory where models can be found - $configData[_BASE_URL]: The base URL related to the controller - $configData[_DEFAULT_SECURITY_POLICY]: Set default policy for objects 2) I have worked security into this MVC implementation. Security checks are still up to the developer to implement but the default policy will be used to determine the default security policy. If set to _TRUSTED, the default policy is to allow access to anyone. If set to _UNTRUSTED, all models/views will have security checks enabled by default. 3) A big problem with Phrame is it will load a lot of unneeded code to process a request. Specifically, all the actions in phrame are loaded. By using the path config information for the views/models, you can dynamically include the right code on demand. 4) Use of session data was completely removed. The main justification is not all applications will use PHP4 sessions and even then, jamming stuff into the session that isn't user specific is a waste of server resources IMHO. 5) Forwards come in two basic types, 1) redirects, 2) model/view forwards. As the first implies, URL redirects is supported and working. However, often it is desireable to forward processing off to a different model or view managed by the current controller. With that said, you can now forward processing on to another model or view requiring no URL redirect. 6) Refactoring, I mentioned this a few times. I saw a need for a model and view factory. Both have been implemented. Additionally, I added a LoaderFactory class. The loader factory allows for any number of configuration sources without requiring changes to the core code. I added this after hearing thoughts on supporting XML config files. My implementation will require the configuration data, regardless of format, to be converted into a PHP array. Right now I have an ArrayLoader which is working but adding an XMLLoader is trivial at this point. 7) the Phrame Mappings and Forwards classes have been dropped. Forwards are simply implemented as an array. When a request is received, only the forwards for the model or view is loaded. Similarly, only the mapping information for the current request is loaded. 8) Documentation, though not a big deal, PHPDoc comments are included and I will be publishing this documentation along with the code when I get a chance. 9) Many applications output views differently. Some echo or print the HTML directly to the browser, others build the HTML in a string and at the end echo that single string. The view implementation is a configuration setting that lets you specify which behaviour is supported and the controller will act accordingly. At this point I am not releasing the code until I have implemented a fairly 'real world' example using this implementation and generated the PHPDoc documentation. I anticipate having this available to this list sometime in the next day or so. -- +-------------------+--------------------------------------------------+ |Tony Bibbs |[R]egardless of what you may think of our penal | |to...@to... |system, the fact is that every man in jail is one | | |less potential fisherman to clutter up your | | |favorite pool or pond. --Ed Zern | +-------------------+--------------------------------------------------+ |
From: Jason S. <jsw...@ya...> - 2003-03-20 15:04:33
|
--- Tony Bibbs <to...@to...> wrote: > 2) I have worked security into this MVC implementation. Security checks > are still up to the developer to implement but the default policy will > be used to determine the default security policy. If set to _TRUSTED, > the default policy is to allow access to anyone. If set to _UNTRUSTED, > all models/views will have security checks enabled by default. I don't really understand the need here. Should the view/actions just query the appropriate model to determine if they should run? For example, you might have a User model that would indicate if a) the user was logged into the site and b) if they had editing permission. In the request to view you might: if (!$o_user->IsLoggedIn()) { trigger_error('you must be logged in to view this page'); header(ERROR_REDIR); } or in the action to update something, you might do if (!$o_user->IsEditor()) { trigger_error('you must have editing rights to change this page'); header(ERROR_REDIR); } This seems like a very application specific issue, what advantage is there to moving it into the framework? > 3) A big problem with Phrame is it will load a lot of unneeded code to > process a request. Specifically, all the actions in phrame are loaded. > By using the path config information for the views/models, you can > dynamically include the right code on demand. Did you look at the comment I posted this past weekend (http://sourceforge.net/mailarchive/forum.php?forum_id=13113&max_rows=25&style=flat&viewmonth=200303&viewday=14)? In it, I documented how to have Phrame only load actions/forms/views/models as required. In my case, actions include specific models that are used in each action, so by loading all the actions all the models would be loaded anyway. > 7) the Phrame Mappings and Forwards classes have been dropped. Forwards > are simply implemented as an array. When a request is received, only > the forwards for the model or view is loaded. Similarly, only the > mapping information for the current request is loaded. Doesn't that eliminate the "loose coupling" advantage that copying Struts gave you in the first place? > 9) Many applications output views differently. Some echo or print the > HTML directly to the browser, others build the HTML in a string and at > the end echo that single string. The view implementation is a > configuration setting that lets you specify which behaviour is supported > and the controller will act accordingly. This is why I think a view factory needs to be application specific as well... Regards, Jason __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com |
From: Tony B. <to...@to...> - 2003-03-20 15:38:03
|
I started to reply but felt it best if I simply just make the code available despite not having a suitable example yet. Here is the code: http://cvs.geeklog.net/chora/cvs.php/MVC_Base?login=2 Sample on it's way sometime soon... --Tony On Thu, 20 Mar 2003, Jason Sweat wrote: > --- Tony Bibbs <to...@to...> wrote: > > 2) I have worked security into this MVC implementation. Security checks > > are still up to the developer to implement but the default policy will > > be used to determine the default security policy. If set to _TRUSTED, > > the default policy is to allow access to anyone. If set to _UNTRUSTED, > > all models/views will have security checks enabled by default. > > I don't really understand the need here. Should the view/actions just query > the appropriate model to determine if they should run? For example, you might > have a User model that would indicate if a) the user was logged into the site > and b) if they had editing permission. > > In the request to view you might: > if (!$o_user->IsLoggedIn()) { > trigger_error('you must be logged in to view this page'); > header(ERROR_REDIR); > } > > or in the action to update something, you might do > if (!$o_user->IsEditor()) { > trigger_error('you must have editing rights to change this page'); > header(ERROR_REDIR); > } > > This seems like a very application specific issue, what advantage is there to > moving it into the framework? > > > 3) A big problem with Phrame is it will load a lot of unneeded code to > > process a request. Specifically, all the actions in phrame are loaded. > > By using the path config information for the views/models, you can > > dynamically include the right code on demand. > > Did you look at the comment I posted this past weekend > (http://sourceforge.net/mailarchive/forum.php?forum_id=13113&max_rows=25&style=flat&viewmonth=200303&viewday=14)? > In it, I documented how to have Phrame only load actions/forms/views/models as > required. In my case, actions include specific models that are used in each > action, so by loading all the actions all the models would be loaded anyway. > > > > 7) the Phrame Mappings and Forwards classes have been dropped. Forwards > > are simply implemented as an array. When a request is received, only > > the forwards for the model or view is loaded. Similarly, only the > > mapping information for the current request is loaded. > > Doesn't that eliminate the "loose coupling" advantage that copying Struts gave > you in the first place? > > > 9) Many applications output views differently. Some echo or print the > > HTML directly to the browser, others build the HTML in a string and at > > the end echo that single string. The view implementation is a > > configuration setting that lets you specify which behaviour is supported > > and the controller will act accordingly. > > This is why I think a view factory needs to be application specific as well... > > Regards, > > Jason > > __________________________________________________ > Do you Yahoo!? > Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! > http://platinum.yahoo.com > -- Tony Bibbs "I guess you have to remember that those who don't to...@to... hunt or fish often see those of us who do as harmlessly strange and sort of amusing. When you think about it, that might be a fair assessment." --Unknown |