SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 62
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking ASP.NET in PHP is possible!

    Hi

    I think this will help those who want to switch from ASP.NET to PHP. I just released a template engine that works exactly like ASP.NET (server controls, event, user control, master page, code behind ...). In fact it is easy because there is no new API to learn, all are PHP functions.

    Download KPF at www.k-edge.com. It is working well but I need help for documentation, and I hope to create a repository of user controls.

    Yor feedbacks for improvement are appreciated.

    Hong Nguyen

  2. #2
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Currently have no plans to use DotNet - defaulting to Java

    Though there are DotNet and PHP developers, and this should be interesting - I'm going to have a look anyways, just going along for the ride

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hello World

    For those who has download but find the tutorial too complex, here is the simplest tutorial:
    1. Download and unzip the files
    2. Set auto_prepend_file and auto_append_file as instructed
    3. Create a new web page, name it helloworld.kpf.php:

    <%@page inherits="HelloWorld"%>
    <?
    class HelloWorld extends kPage{
    function page_load(){
    $this->hellobox->value='Hello World!';
    }
    function cmdReply_click(){
    $this->hellobox->value='Welcome!';
    }
    }
    ?>
    <form runat="server">
    <input type="text" runat="server" id="hellobox">
    <input type="submit" runat="server" id="cmdReply" value="reply">
    </form>

  4. #4
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Frankly this isn't any better than anything you can do using WACT. At least WACT doesn't waste it's time trying to emulate a completly different language.

  5. #5
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice stuff. Good to see PHP developers working on this angle. You might be interested to see what's going on with WACT for comparison. WACT isn't attempting to be a direct ASP.NET port though.

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might be right, but as I said in first post, this appeals more to ASP.NET converts :-). Anyway I don't port all ASP.NET tag, only stick to HTML, with only repeater as exception, and I feel that this is extreamly easy to learn. Here is implementation of datagrid, via repeater:

    <?
    class Datagrid extends kPage{
    function page_load(){
    //create data source with 2 column: column1 & column2
    $rs=array(array('column1'=>'test1','column2'=>'test2'),array('column1'=>'test3','column2'=>'test4'));
    $this->datagrid->datasource=&$rs; //can also use ADODB
    $this->datagrid->databind();
    }
    }
    ?>
    <table >
    <tr><td>column1</td><td>column2</td></tr>
    <repeater runat=server id=datagrid>
    <itemtemplate>
    <tr><td>#column1#</td><td>#column2#</td></tr>
    </itemtemplate>
    <alternatingitemtemplate>
    <tr style='background-color:lightblue'><td>#column1#</td><td>#column2#</td></tr>
    </alternatingitemtemplate>
    <edititemtemplate>
    <tr style='background-color:lightgreen'><td><input runat=server value=#column1#></td><td>#column2#</td></tr>
    </edititemtemplate>
    </table>

    Notice that the above web page can be edited directly in Dreamwaver/Frontpage..., you will see a table with 3 rows, first is for itemtemplate, 2nd is for alternatingitemtemplate and 3rd is for edititemtemplate.

    Additional tag like asp:calendar is not in the core but implemented as user control. See my sample page www.k-edge.com/example/admin.kpf.php where I use a HTML editor user control called htmlarea. That page also demonstrate datagrid with edititemtemplate.

  7. #7
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Being frank for a moment, looks like you've got an interesting prototype - not many people in PHP are thinking along these lines yet, most being caught up with arguments of Smarty vs. PatTemplate vs. Whatever.

    The question now is making it solid, fast and extensible. From glancing over the code, looks like you were considering a way to cache generated PHP - that's worth exploring for performance. To make the code more solid, suggest breaking up some of the classes and methods you've got into smaller pieces and writing unit tests for them (http://www.lastcraft.com/simple_test.php). To be extensible (particularily allow others to add their own 'controls'), you need some way they can just plug their code in.

    Overall it's a big project and alot of work. If you're ever interested in helping out with WACT instead (currently team of 6 working on it), check out the source from CVS and join in the mailing list - it's a group decision who joins so it's a good idea to get yourself known.

  8. #8
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's exactly the point when I publish this code. I would like others to help with unit test and extend it. I don't think I could join WACT due to my limited time, and I'd like to stick to my principle that there's no new API to learn (actually, there is a few, like isPostBack(), Validate(), ...). I know WACT is more extensible for enterprise apps, thanks to its models like MVC, but I believe there's a use for my aproach when developers need to create quick web applications.

    Right now others are already able to plug in their controls. Just create another page, then call it in the main page as a tag, or dynamically load it using method 'load', all life cycle of the called page (page_load, post back events...) is maintained. HTMLAREA is a simple example, but it can be a more complex ones like a calendar, a datagrid,... (Exactly how ASP.NET user control works). That means, I prefer to keep the core template small (only HTML tags).

    Each KPF page is parsed once and stored in 'compiled' folder with real PHP code (unless the page changes). I'm interested to learn ways for caching that other template engines implement. And to extends it for unit caching like ASP.NET.

    So thanks for your suggestion but I'll be happy if instead you can help me out with this project.

  9. #9
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Best bet then is to get yourself a Sourceforge account and publish the code there with CVS etc.. As a collaboration tool, Sourceforge is excellent.

  10. #10
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sourceforge

    I must admit that I'm a Windows user and don't know how to use CVS :-) (I'm using Subversion however). But I will try when I can. Right now the code source is available so maybe you (and others who are interested too) can communicate with me (email, forum,...) to get familiar with the code first?

    Thanks

  11. #11
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Source Forge would be your best bet, adding to what Harry has said.

    If you need developers to work on your code, give it a go - you'd be suprised at the results

  12. #12
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I must admit that I'm a Windows user and don't know how to use CVS :-)
    Try here: http://www.sitepoint.com/article/harness-power-cvs-site - wrote this specifically for Sourceforge accessed from Windows.

  13. #13
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by HarryF
    Try here: http://www.sitepoint.com/article/harness-power-cvs-site - wrote this specifically for Sourceforge accessed from Windows.
    Thanks. I will plan about hosting at SF again. Actually I tried CVS via SF a few times before and it didn't work well for me. Subversion on the other hand seemed very easy because I got it up within 5 minutes using TortoiseSVN (integrated with Explorer), connecting to Apache mod_dav.

    Another point: while looking for help on the codes, I think it is more on suggestion for improvement (especially performance) rather than to develop new codes. The engine is already completed with all nice features from ASP.NET. I can port IbuySpy portal, .NET Petshop, IbuySpy Store,... within one day.

  14. #14
    SitePoint Guru
    Join Date
    Dec 2003
    Location
    oz
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting Hong.

    As I learnt many important concepts about development such as templating to seperate code and display, and other concepts, I realised that .NET was amazingly well designed. It has so much built in that gets you to code better by default, where as with raw php, you hve to add in with php and know about the concepts before using them - hence most peoples php code ends in a mess since most php code is easy and hence written by novices.

    I use many concepts from .NET when coding php, includeing making a page object with constructor, etc .. that .NET languages have automatically.

    I've thought it'd be nice to have this already available in php. So nice work with your module!

    I've not done alot with .NET tho, and cant remember much about runat, and other stuff, etc ... But will get back into it soon.

    I should check out wact soon tho to see what all the fuss is about. I think i took a quick look and didn't seem so simple and easy, and since my time is limited atm, I didn't explore further. I should look again soon

    Well done with this though Hong!

    Regards,
    Eli

  15. #15
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lazy_yogi

    Well done with this though Hong!

    Regards,
    Eli
    Thanks for compliments. My target is to get more developers try this out. Frankly I know ASP.NET concept is hard for PHP programmers. When I first tried to move from ASP to ASP.NET I was scared at how the ASP fundamentals changed all of the sudden. I took me about 1 month go through tutorials at www.asp.net to really start the first web page.

    ASP.NET design covers and speeds up all common web application designs with its server controls, events... However I still haven't done any real apps with it, because you would need VS.NET. I can't stand that you need to create a project just to have a web page, and VS is too bloat. Sure you can use text editors also but how to remember dim xxx as system.web.UI.blah..blah every time?

    So all my real applications are still in PHP, but I missed the ease of ASP.NET, and now KPF is the missing link. The core works are still PHP, just pack it in a class and there you have KPF.

  16. #16
    SitePoint Enthusiast NativeMind's Avatar
    Join Date
    Aug 2003
    Location
    USA
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Harry, hongk: have you seen HTML_Template_Flexy from PEAR?

  17. #17
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hongnk
    I think this will help those who want to switch from ASP.NET to PHP. I just released a template engine that works exactly like ASP.NET (server controls, event, user control, master page, code behind ...). In fact it is easy because there is no new API to learn, all are PHP functions.
    You may want to consider submitting to the PHP Classes site.

    Besides getting immediate exposure to over 60,000 PHP developers that are eager to learn about new packages, you may also qualify to gain recognition and prizes to a new initiative called PHP Programming Innovation Award that repeats every month starting now.

    Just to you have an idea of what kind of projects may qualify, take a look at the current list of award nominees.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  18. #18
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mlemos
    You may want to consider submitting to the PHP Classes site.
    Thanks Manuel, I will do it. Did you try my class already, any feedback?

    Hong

  19. #19
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Singapore
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by NativeMind
    Harry, hongk: have you seen HTML_Template_Flexy from PEAR?
    Just take a look at Flexy but if I'm not wrong it is of the same kind with other engines, where you need to use some special tag for your template. I'd like to emphasize that with my engine, you just need to know the work flow (load, postback events) then use only standard PHP functions to write your code. Though this is no innovation, there are some neat features that I find it is better than ASP.NET itself.

  20. #20
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is javascript required for asp.net? I know nothing about it!

    Matt

  21. #21
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have JScript for DotNet as well - DotNet in my understanding can use C, Java, Javascript amongst other languages easilly, though IMO I think DotNet was largely developed for tool based development, rather than code based development.

    It's good, but by no means great Java still holds number one spot to me

  22. #22
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Widow Maker
    You have JScript for DotNet as well - DotNet in my understanding can use C, Java, Javascript amongst other languages easilly, though IMO I think DotNet was largely developed for tool based development, rather than code based development.

    It's good, but by no means great Java still holds number one spot to me
    So, in order to use this template engine, the client must have js enabled?

    Matt

  23. #23
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I've answered my own question here. I tried out the template framework and it's very nice. Well done! The only thing is the javascript part. Like I said above, I don't know anything about asp.net, but it seems so limiting to me that you'd have to have JS enabled. If you base your website off of this system, that's a whole website that isn't going to work if you don't have JS enabled. I know that the stats are hi for JS (+ 95%) enabled browsers.

    Is this something that most developers feel comforatble with? If the general opinion is that most people just "should" have JS enabled, then I'd feel good about using something like this.

    Matt

  24. #24
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    Norway
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is indeed a very interesting project. After working with .Net for a few years I feel the template handling with code-behind files is really a big step forward when programming webpages.
    I will seriously consider using this approach on my next big PHP project (that I've just started).

  25. #25
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    mwmitchell, why would you need to have JavaScript enabled?
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •