PHPx framework

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

PHPx framework

Post by crazycoders »

I have started building a framework for php. (Not another one you say, we have enough thank you)
I have yet to see something like mine. It is based on ASPX (or ASP.Net) but it's not focused around the .Net framework but more on the postback handling idea that ASP.Net uses. It is extremely simple to use compared to those other frameworks out there. I'd like your input on the first post about it on my blog, thanks.

http://www.allianceunisport.com/index.p ... ework.html
Last edited by crazycoders on Thu Mar 12, 2009 1:02 pm, edited 1 time in total.
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

I see several people looked at the post but i got no comment at all, anyone care to actyally comment the strategy i'm exposing for my framework? Anyone interrested in knowing more?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHPx framework

Post by Christopher »

Can the framework with examples be downloaded? What is the license?
(#10850)
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

No not yet since it's not complete at all, but what you see on my blog can give you a good example of what is available:

Features:
Postback handling
Viewstate
Object oriented programming with event handlers
Component based programming
Declarative syntax and codebehind file

Components current developped:
system_forms_web_label (50%, styles left to be implemented)
system_forms_web_button (50%, styles left to be implemented)
system_forms_web_fontstyle (99%, finishing touches)

Ajax
Will not support ajax for now but already designed to support strong postback and change handling via ajax
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

Example of a declarative syntax page (index.phpx)

Code: Select all

<phpx>
    <library namespace="system.forms.web.buttons" library="xstdb" />
    <library namespace="system.forms.web.debuggers" library="xdgb" />
    <library namespace="system.forms.web.labels" library="xstdl" />
    <library namespace="system.forms.web.styles" library="xcss" />
    <page codebehindfile="index.php" codebehindclass="indexpage">
        <fontstyle id="pagefont" rule="body" fontfamily="Arial, Helvetica, sans-serif" fontsize="12px" fontstyle="inherit" />
        <div style="padding-left: 10px" class="pagefont">
            <label library="xstdl" id="message" text="Nothing to say" blocktype="inline" />
            <button library="xstdb" id="sayhello" text="Say hello" onclick="mypage.sayhello_click" /><br />
            <button library="xstdb" text="Postback with no changes" /><br />
            <button library="xstdb" id="restoremessage" text="Reset message" /><br />
            <button library="xstdb" id="changesizebig" text="Change font to bigger font" /><br />
            <button library="xstdb" id="changesizesmall" text="Smaller font" /><br />
            <button library="xstdb" id="swapbold" text="Swap bold state" /><br />
            <button library="xstdb" id="swapitalic" text="Swap italic state" />
        </div>
        <inlinedebugger />
    </page>
</phpx>
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

Example of a codebehind file

Code: Select all

<?php
class indexpage extends system_forms_web_page {
    
    //Constructor of the page object
    public function __construct(system_framework $framework){
        parent::__construct($framework);
    }
    
    //Initialize of page
    public function initialize(SimpleXMLElement $content){
        parent::initialize($content);
        //Bind the button event
        $this->sayhello->addHandler('onClick', $this, 'sayhello_click');
        $this->restoremessage->addHandler('onClick', $this, 'restoremessage_click');
        $this->changesizebig->addHandler('onClick', $this, 'biggertextsize');
        $this->changesizesmall->addHandler('onClick', $this, 'smallertextsize');
        $this->swapbold->addHandler('onClick', $this, 'setbold');
        $this->swapitalic->addHandler('onClick', $this, 'setitalic');
    }
    
    //Button handlers
    protected function sayhello_click(system_forms_web_button $sender, array $args){
        $this->message->text = 'Hello';
        $this->message->blocktype = LABEL_BLOCKTYPE_BLOCK;
    }
    protected function restoremessage_click(system_forms_web_button $sender, array $args){
        $this->message->text = 'Nothing to say';
        $this->sayhello->text = 'Reset to "hello"';
        $this->message->blocktype = LABEL_BLOCKTYPE_INLINE;
    }
    protected function biggertextsize(system_forms_web_button $sender, array $args){
        $this->pagefont->fontsize->size *= 1.5;
    }
    protected function smallertextsize(system_forms_web_button $sender, array $args){
        $this->pagefont->fontsize->size /= 1.5;
    }
    protected function setbold(system_forms_web_button $sender, array $args){
        if($this->pagefont->fontweight == 'bold'){ $this->pagefont->fontweight = ''; }
        else{ $this->pagefont->fontweight = 'bold'; }
    }
    protected function setitalic(system_forms_web_button $sender, array $args){
        if($this->pagefont->fontstyle == 'italic'){ $this->pagefont->fontstyle = ''; }
        else{ $this->pagefont->fontstyle = 'italic'; }
    }
    
}
?>
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

Forgot to say that there is also an inlinedebugger component that is 50% complete, styling is left to accomplish
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

I have trouble finding out which nodes have text data in them using simple xml, so i have to rewrite everything so far to use domxml... yay!
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

Allright fixed, so if interrested in knowing more arboprint (or anyone else) just ask away
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHPx framework

Post by Christopher »

Well to be honest I am not that interested in yet-another-framework, especially one based on ASP.net. And you haven't said whether you are going to release the code or what the license is. I am also of the opinion that a solo coder cannot produce a framework that more than about three people would like enough to actually use.

Man ... do I always sound like such a downer and hater?? ;)

That said, certainly discussing frameworks can be interesting and informative. When you have something that people can download and try I think you may get some feedback.
(#10850)
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

K thanks, i was more looking into a development discussion than a test, but it's ok.

For the licensing, i don't know what are the different licensing options. I guess if you can tell me which one copes best with my description then it will be it:

- Free for use and distribution as part of a software suite or web application
- Cannot distribute anywhere else than on mirrors or official site
- Change at your own risk
- Do not incorporate as part of your own framework, help me develop this one instead
- Do not remove author, add your author info if you change stuff
- Send in changes if you do changes, (to see if that change can be made part of base product)
- No responsibility can be taken from author or if user changes code

Am i missing something, does it fit in with a known license you know (i guess you are talking about those GPL or GNU things we see from time to time right?)
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

In regards to
I am also of the opinion that a solo coder cannot produce a framework that more than about three people would like enough to actually use.
I wonder why? Because you know that no one can actually produce such a framework that would achieve your highest standards? Or simply because you are not a framework type guy? Or maybe because its based on M$?

:wink:

That said, who said i was solo? I'm open to propositions!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHPx framework

Post by Christopher »

Creating a design that you are happy with is pretty easy. To make a second designer happy is difficult. Keep adding designers and experience the unhappiness asymptote. ;)
(#10850)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHPx framework

Post by Benjamin »

@arborint, you are seriously full of all sorts of wisdom. That's awesome. And no, I'm not being sarcastic. How long have you been in this field?
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: PHPx framework

Post by crazycoders »

To respond to the licensing, i read a little bit about it. I will probably release it under GPLv3 to make it copyleft and prevent forks. I prefer people help me develop a strong framework than starting to copy and derive from my work. Second reason is that if they go and change the way it works, they may change the philosophy behind it and fork to a completly different system whilst not having to code the core of it...

Am i right to choose this? If i'm not wrong it responds to my previous needs:
(Green = yes, Orange = not sure, Red = doesn't)

- Free for use and distribution as part of a software suite or web application
- Cannot distribute anywhere else than on mirrors or official site
- Change at your own risk
- Do not incorporate as part of your own framework, help me develop this one instead
- Do not remove author, add your author info if you change stuff
- Send in changes if you do changes, (to see if that change can be made part of base product)
- No responsibility can be taken from author or if user changes code
Post Reply