Your first windows application, written in PHP ONLY !!

Discussion in 'PHP' started by krakjoe, Jun 13, 2007.

  1. #1
    Oh yeah, here we go ....

    I'll assume already that you know php, and are confident that you can follow instructions and function prototypes similar to those you see @ php.net, that's pretty much all you need.

    Firstly, a little bit about how this is done, so it doesn't seem like voodoo or something to you.

    As you know php is an extendible language, you can pretty much write any C code you want to ( c++ if you're good enough ) and have php execute it, and I'm sure youre aware of PHP-GTK, well for some time now there has existed a library going by the name of WinBinder, what winbinder does is fuses the power and glory of php with the accessibility of windows and it's own native API to allow even novice php programmers to build fully featured windows applications using thier existing knowledge and skills.

    I won't go into how the Windows API works, I don't need to you don't need to know.

    Here is some pseudo code with the structure of a WinBound application

    
    <?php
    // first include the wb functions that are contained in some php scripts distributed with winbinders installation package
    include('winbinder.php');
    // next you need to create a window probably for the user to interact with
    $mainwin = wb_create_window( [ function args ] );
    // next you need to draw controls on the above window
    wb_create_control( $mainwin, [ function args ] );
    // next you need to set a handler for that window, this function will handle the button pushes and tab changes etc in your application, it's the "brains" of the operation so to speak
    wb_set_handler( $mainwin, 'process_my_window' );
    // next we need to define the function and all it's procedures, notice this function has at least two parameters, the window it's for, and the id of the control being clicked, id's are specified in wb_create_control and normally defined before that, passing them works and trying to be as simple as I can be.
    function process_my_window( $window, $id )
    {
        switch( $id )
        {
            // this ID is predefined by wb, it's for the exit button, and you MUST put one in
            case IDCLOSE:
                wb_destroy_window( $window );
            break;
            
            case IDC_BUTTON:
                // your other cases and buttons and what not here
            break;
        }
    
    }
    // the next step is to tell wb to start looping infinitely with
    wb_main_loop( );
    ?>
    
    PHP:
    Writing windows applications from php really is as simple as that, please take a look at winbinder and it's documentation, and any questions you might have regarding it's usage feel free to ask if you don't get a response from the forums @ winbinder.

    Once your applications are written, you'll notice they are still .php(w) scripts, however there are remedies for that, one of them exists : phpCompile : and of course has my name on it, so is far superior to anything else you might find, and now your php is an actual windows .exe that you can distribute like the big boys do .....

    phpCompile is also suitable for making console applications from php, no further knowledge needed there, you write php scripts to do whatever you need and can turn them into an .exe to do whatever you need anywhere there is windows
     
    krakjoe, Jun 13, 2007 IP
    wing and einsteinsboi like this.
  2. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Wow, that's so awesome! I never even knew there was anything like this with PHP!

    I saw the title and thought you were a crackpot lol ^.^
     
    HypertextFever, Jun 13, 2007 IP
  3. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #3
    I was battling with php-gtk at the time of discovery, and wondering how I could make it look like the applications were supposed to be on windows, I even started to consider porting wxWidgets to php, when I came across it - it was like a hundred birthdays at once.

    I know c, but it's no fun to use, writing in php is enjoyable, I have no idea why, but anyone who does it knows it is, now I only use c to hack php up to make my compiler, so hopefully I'll never have to write another line of c ( outside of php ) again, not ever ......

    What's even more suprising, your standard c/cpp program will be about 3-4 megs and probably depend on system dlls, however a winbinder application to do the same, packed with phpCompile will take up much less room than that, and depend on nothing but windows itself ( possibly phpCompile.dll, if you use the beta, which you really shouldn't right now, not for learning ).......
     
    krakjoe, Jun 13, 2007 IP
  4. einsteinsboi

    einsteinsboi Well-Known Member

    Messages:
    1,122
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    140
    #4
    This is really cool. I am just starting to learn php, so I know this is going to come in handy somewhere down the road. Thank you so much for sharing. Some green for you!

    I just subscribed to your rss feed on your site, pretty nice stuff!

    thanks again!
     
    einsteinsboi, Jun 13, 2007 IP
  5. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Hey man, this is absolutely fantastic! Guys like you is what makes the php community great.

    Big thanks for doing this :)
     
    wing, Jun 13, 2007 IP
  6. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Haha! You krak me up Joe!

    I got these bad boys installed, and can run the phpw's from the examples folder (drool, so awesome).

    But I'm having trouble with two things maybe you can help me out with:

    1.) The "form editor" doesn't work. Have you ever had problems getting it to launch. It tells me to check my installation -.-

    2.) When I try and compile a phpw (like the digiclick.phpw) I can get it to compile and all, but then it doesn't run when I double click on it. I only include the php_winbinder.dll extension, should I be including more? Any ideas what I'm doing wrong?

    Thanks Joe!
     
    HypertextFever, Jun 13, 2007 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    Ok, the structure of your application should look like :

    C:\projects\your_project <-- root
    C:\projects\your_project\include <-- among other things, the winbinder includes should be copied to here, and other files your application depends on ( probably nothing at first )
    C:\projects\your_project\main.php <-- your main.php file

    I dunno why the form editor isn't working for you, it might be that a previous installation of php is intefering with it and so http://krakjoe.com/temp/form_editor.zip there it is packed with phpCompile

    While your on a learning curve, you mind find that using the WinASM ide for designing interfaces might be better for you, http://www.winasm.net/, wb has an auxiallary parse_rc function to load the rc scripts made by winasm, choose file -> new -> rc file

    If you look in the docs folder of phpCompile there is a quick tutorial and a faq that should answer most of your initial questions.......
     
    krakjoe, Jun 13, 2007 IP
    ansi likes this.
  8. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #8
    :p I've known about this for a while - but I STILL can't think of an application I'd need!
     
    dp-user-1, Jun 13, 2007 IP
  9. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Joe, Thanks man! I'll work on it more tonight (when I'm not at work haha)!
     
    HypertextFever, Jun 13, 2007 IP
  10. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    #10
    I got many helps from this forum.and here many class PHP coders helped to grow my knowledge higher in PHP.krakjoe is a magician of PHP.thanks a lot man.This topic shows me a way to discover a new world of PHP :D
     
    coderbari, Jun 13, 2007 IP
  11. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #11
    I'm glad you like it, and thanks for the compliments :) ......
     
    krakjoe, Jun 13, 2007 IP