Jump to content

check out my MVC framework


mrfritz379

Recommended Posts

Hey all, I just uploaded the source code to a framework I've been working on for a little while now. I'm not looking for a critique, so much as I'm looking for developers to help me continue to work on it (though criticism is welcome). It's a very alpha release, so I know there's lots to fix.

[url=http://dev.fritz-works.com]demo[/url]
The demo is a quick Test action that I threw up to show how the framework can handle multiple request protocols and always respond correctly. It accepts SOAP requests, XML-RPC requests, as well as standard POST/GET which will output in WAP when appropriate or when AJAX is requested, outputs raw XML. Just enter a name into the text box, select an output method and the request/response cells will show the text that is sent/returned.


If you decide you are interested in helping out or would like to download the source, the homepage is [url=http://phritz.fritz-works.com]phritz.fritz-works.com[/url]. There's also a wiki up that doesn't have a whole lot of info, but lays out the basics pretty well.

From the wiki:
[quote]
[size=14pt]What is Phritz?[/size]

Phritz is a lightweight, extensible MVC (Model View Controller) framework for web application development. The main goal and purpose of Phritz is to allow developers to create display independant, standard-compliant programs in PHP.

[size=14pt]How does it work?[/size]

Phritz works by parsing incoming requests to determine the format of the request. These requests are then wrapped in a simple Request object that is passed to a specified Controller which then passes that request to the requested method. Responses are returned in a simple Response object that is passed to the View object that corresponds to the type of request made (i.e. SOAPView,RPCView, HTMLView, etc). The View object formats the response variables appropriately and displays the finished result.

[size=14pt]What display types does Phritz support?[/size]

Currently, Phritz supports output in xHTML, WML, SOAP, XML-RPC, and AJAX(XML). I am also planning on supporting JSON and RSS.

[size=14pt]What's the point?[/size]

The trends toward non-standard access of web data (i.e. not through a browser) are undeniable. The use of Web Services is increasing, creating "mash-up" websites that people can use to access the content of any number of other sites. Desktop gui applications such as Flock, Firefox, Thunderbird, etc. are increasingly utilizing the web services of sites to allow users to obtain data without ever loading a web page. In addition, the use of mobile browsers is increasing, forcing companies to rewrite entire applications to output WAP format instead of standard HTML. The goal of Phritz is to facilitate the move toward these trends by allowing developers to create applications that offer these web services and WAP compatible content without having to go through the hassle of coding them manually.
[/quote]
Link to comment
Share on other sites

[quote author=Daniel0 link=topic=108924.msg439187#msg439187 date=1158904291]
I guess a mod would move it. I clicked the "Report to moderator" link, so I guess that if they find it misplaced they will move it.
[/quote]
Great. Now they're going to think I'm posting porn or causing some trouble of some kind.  ;)
Link to comment
Share on other sites

Hi, first off - nice work getting your own framework together, I know from experience with quite a few developers it's not always an enjoyable task :)

Also, please take this as constructive criticism - not a slating.

Your classes: for example your HTMLView class does too much. There is too much error handling, and it also has a lot of assumptions - some of which I might add are not good ones to make. A class is to do a specific job, anything that is not directly related to the object should be handled elsewhere - as such, the HTML View class should deal with presenting HTML, and nothing but presenting HTML. From the code I can see it deals with error handling, logging (not good to assume the developer will want every error logged.) This should be separated - you already have an error/exception class, so use it :)

Also, I don't mean to burst your bubble.. but strictly speaking it's not an MVC framework, too much of the Domain Logic (model) is in the view, too much of the view is in the controller etc. etc. :)

Also as more of a generic coding point, your catch blocks look like this:

[code]<?php

catch (Exception $e) {
    switch (get_class($e)) {
    //etc..

?>[/code]

They should read:

[code]<?php

catch (SubClassException $e) {
    // do something for a SubClassException;
} catch (OtherSubClassException $e) {
    // do something for an OtherSubClassException;
} catch (Exception $e) {
   // do something for an unexpected exception;
}

?>[/code]

You've also tight coupled a lot of your data and directory structures etc. Tight Coupling is bad, especially in frameworks :)

I also dislike the use of as many constants as you have done, but that is personal preference (but is also a form of tight coupling and also exposes such couplings to the discretion of the code outside of the class which is not always favorable.) I prefer to use a settings object.

Hope this helps :)
Link to comment
Share on other sites

Hey, thanks for the feedback! I know there's still a lot of work to be done on the project, particularly in the delegation of duties among the various classes. This was mostly just a prototype announcement to show what the ultimate goal of the framework is, that is to allow clients to send requests in any number of formats and always receive an appropriately formatted response.
There are a couple of posts on my forum that mention quite a few TODOs regarding much of what you stated.  ;)

Regarding the mvc structure, I'm not sure where the errors are that you mentioned. While there is currently no real Model class implemented (you can read the post on my forum about what I'm thinking regarding that issue) I thought that the seperation of duties was pretty clear regarding the controller/view classes. The page controller methods read the request information sent and pull the appropriate data (the test module controller just appends the provided firstname parameter to a string-- no need to pull data from anywhere) and returns the response object which is then passed to the view and assigned as template parameters. Perhaps you have some suggestions that I can use to make the lines more clearly defined? :)

Regarding the exception handling in the Views, I really only did that to save on some typing since all of the error handling for the various exceptions was exactly the same except for the error message that was to be printed. But you are right as far as the amount of error handling that takes place within the view. Currently it catches all the exceptions that are thrown from the template processing. I need to set up a general Exception handler within the error class (right now it is only set up to handle trigger_error()) so that uncaught or fatal exceptions can be passed to it and then output the appropriate display. Just one of the many many many many things I haven't gotten around to yet.

I appreciate you taking the time to take such an in-depth look. If you are interested in following development, there is currently a CVS on the homepage. Its a Xoops CVS module that I'm not particularly fond of, however Sourceforge has just informed me that my project was approved today, so the Source and version info are going to be available there pretty soon. If you are interested in taking part in the development, please feel free to sign up in the forums on the homepage :).
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.