Results 1 to 7 of 7

Thread: PHP to EXE compiler

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default PHP to EXE compiler

    Well, this thing is pretty awesome.

    Obviously PHP isn't the best for desktop stuff anyway, but it's fun to play with and some functions make it very useful, like built in FTP setup, etc. Or even for an automatic webpage generating app, since that's it's usual function. Just save as a file, not raw output.

    The basics: The program runs through dos. Windows only. (EXE.. duh.) Linux? I dunno... I don't think so.

    To use:
    1. get zip at site: http://www.bambalam.se/bamcompile/
    2. unzip
    navigate to its directory from cmd prompt.
    3. start>run... 'cmd'
    4. use the command "cd" to change directory:
    ex: "cd Desktop\bamcompile"
    5. Place PHP script to be compiled next to bamcompile.exe (same directory)
    6. in the cmd prompt, at that directory, type:
    ex: "bamcompile test.php"
    variations:
    "bamcompile -c test.php" gives compression.
    -e:something.dll allows a DLL to be embedded
    And a bit more.

    Anyway.... working great... fun stuff.

    Note: Some functionality of exec() and system() commands in PHP to use the command prompt, like exec('start some.htm'); would pop a webpage up in the browser... like open the page.

    For the experts here, two things REALLY frustrate me. I've tried a lot, but can't get either to work.

    1. Input from the user at a prompt. I've tried 'prompt' and it kinda works, but can't call that with PHP (just manually typing at the prompt), so doesn't do much.
    You CAN get input if running from the dos cmd prompt, so you type filename.exe input1, then input1 is the value of $argv[1]. BUT... that's ONLY from the command prompt. If running by starting the exe independandly, you can't get that.
    It's possible for me to deal with the cmd prompt, but I would like to generate something reasonably user friendly.

    2. I was trying to make an ftp uploading script. AND watch the filesize as it uploads. Well... I got both going. Problem is that it can only do a single process at a time. No big deal there. So just run two programs. However, if one uses exec('start watcher.exe'); then it just waits til that program is DONE before continuing in the first. It's like a mini branch, but not a new program.
    Any suggestions here? Really trying to come up with something.
    The only option I can see now is using a batch file to begin with. Using a batch file or an indirect route the many .bat/.exe's doesn't do anything once it's going. But the .bat file, (I think, from limited tests) can create two instances at once. But then they could only communicate JUST through writing to a text file or something. Ew. By starting it at a certain time, it can know to look for the most recently created file at THAT point... not just wait around until it thinks the other one is going.
    Note: some of this also functions with the cmd prompt, but not when run as independant EXEs.
    also, using the '-w' parameter which hides the windowed mode, or some such, appears to help in certain ways, but not to a fully workable solution.

    So... play, and let me know if you can help with either of the problems.


    Note: all functions like directory listings, include (even from the net), etc etc. work just fine. echo outputs to the cmd prompt as text. Html is worthless, so start thinking about php in a different way.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    1. get zip at site: http://www.bambalam.se/bamcompile/
    2. unzip
    navigate to its directory from cmd prompt.
    3. start>run... 'cmd'
    4. use the command "cd" to change directory:
    ex: "cd Desktop\bamcompile"
    5. Place PHP script to be compiled next to bamcompile.exe (same directory)
    6. in the cmd prompt, at that directory, type:
    ex: "bamcompile test.php"
    variations:
    "bamcompile -c test.php" gives compression.
    -e:something.dll allows a DLL to be embedded
    And a bit more.
    There's a much easier way, from explorer.exe: simply click and drag the PHP file icon onto the bamcompile.exe icon.
    1. Input from the user at a prompt. I've tried 'prompt' and it kinda works, but can't call that with PHP (just manually typing at the prompt), so doesn't do much.
    You CAN get input if running from the dos cmd prompt, so you type filename.exe input1, then input1 is the value of $argv[1]. BUT... that's ONLY from the command prompt. If running by starting the exe independandly, you can't get that.
    It's possible for me to deal with the cmd prompt, but I would like to generate something reasonably user friendly.
    You can read from the shell by reading from 'php://stdin'. If you're looking for user-friendliness, though (especially on Windows, whose primary target group doesn't actually know what a command prompt is) your best bet is to write a GUI interface, perhaps using PHP-GTK.
    2. I was trying to make an ftp uploading script. AND watch the filesize as it uploads. Well... I got both going. Problem is that it can only do a single process at a time. No big deal there. So just run two programs. However, if one uses exec('start watcher.exe'); then it just waits til that program is DONE before continuing in the first. It's like a mini branch, but not a new program.
    Any suggestions here? Really trying to come up with something.
    PHP's threading support is... well... non-existant, really. It's primarily designed for web scripting, and there just isn't a call for multi-threaded web applications.
    Note: all functions like directory listings, include (even from the net), etc etc. work just fine. echo outputs to the cmd prompt as text. Html is worthless, so start thinking about php in a different way.
    It's true that it's often possible to write an application in PHP, but PHP is still much too web-centric for serious application development; I suggest you check out Python if you're looking for something more suitable. This bamcompile application seems like a waste of time, overall; it doesn't really compile the code, it merely embeds it into an instance of the PHP interpreter. About its only worthwhile feature is the compression. There are no other significant advantages over simply providing the interpreter and a shortcut or minimal binary:
    Code:
    char *args[3];
    
    int main(int argc, char **argv) {
      args[0] = "php";
      args[1] = "data/main.php";
      args[2] = 0;
      execv("interp/php.exe", args);
      return 0;
    }
    This code assumes the directory structure is set up like so:
    Code:
    run.exe
    data/
    data/main.php
    interp/
    interp/php.exe
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, I'm just looking to play and quickly create some apps. Learning a new language would be something I would/will do when I have the time and need for a real language.
    Right now, however, I'd like to fake it just for some simple tasks... would be helpful.

    Do you have any suggestions of how I would make a workaround work, such as getting user input (without any fancy steps), or how I could run two DIFFERENT windows at once, both started from a single window? I don't need multiple threads, but just different windows running. One could monitor the size of the file as it's being uploaded. The other actually uploads. In fact, I've done this and it works just fine. But I needed to start both manually. The auto-start of both is problematic.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, I'm just looking to play and quickly create some apps. Learning a new language would be something I would/will do when I have the time and need for a real language.
    Like I said, a batch file, shell script, or even a Windows shortcut would do just as well.
    Do you have any suggestions of how I would make a workaround work, such as getting user input (without any fancy steps), or how I could run two DIFFERENT windows at once, both started from a single window? I don't need multiple threads, but just different windows running.
    Well, on systems with bash or another decent shell (Mac OS X counts) you can do something like:
    Code:
    shell_exec('php script2.php &');
    I suspect there's probably an equivalent for DOS, but I'm not sure.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Alright. I'll play with it. Batch files seem to be included in the "I won't do two things at once" oddness.
    Also, I should have said AND not OR, as I also want to know how to get user input... no ideas there?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Reading from php://stdin should be fine.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by Twey View Post
    Like I said, a batch file, shell script, or even a Windows shortcut would do just as well.Well, on systems with bash or another decent shell (Mac OS X counts) you can do something like:
    Code:
    shell_exec('php script2.php &');
    I suspect there's probably an equivalent for DOS, but I'm not sure.
    How about
    Code:
    shell_exec('php.exe script2.php');

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
  •