Slashdot Mirror


Skinnable, Portable Desktop Apps In PHP

joeldg writes "With the new Zend coding contest getting underway, a lot of PHP coders are hacking out some amazing new test code. In that vein and in response to the lack of skinning with PHP-GTK apps, I just finished up writing a tutorial with source code for doing skinnable desktop applications in PHP that run on both Linux and Windows."

36 comments

  1. Slashdot by coyote4til7 · · Score: 4, Funny

    ... leading cheerleader for in-appropriate php apps

    --

    the clock on the wall says 4 til 7
    1. Re:Slashdot by JabberWokky · · Score: 3, Interesting
      Several of my CLI apps are now PHP. It is a good language for interfacing to databases and especially good at creating CLI tools to manage websites written in PHP. From there it was a natural jump to do things like manage my mp3 collection in PHP, a couple cron jobs and things like that.

      PHP compiled in CLI mode is pretty good as a quick tool to make other tools. I'm a die hard shell scripter, but the need to interface with web facing code on many servers led me down the path of using it, and it has really proven to be fairly good. There's a lag on slow machines when first executed, as it compiles to memory whenever a script is executed, and that's about my only complaint.

      --
      Evan "Not as portable as sh, not as common as perl"

      --
      "$30 for the One True Ring. $10 each additional ring!" -- JRR "Bob" Tolkien
    2. Re:Slashdot by Anonymous Coward · · Score: 1, Insightful

      Would it be that much of a intellectual hurdle to switch to Perl, where you can leverage CPAN? You know, the whole "right tool, right job" mantra?

      Syntatically they might as well be the same langauge except the hash and array symbols.

    3. Re:Slashdot by joeldg · · Score: 2, Interesting

      I think it is quite appropriate saying it is for 'rapid' prototyping of windowed apps that can be used by both the developers (linux) and managers (windows) and they are both looking at the same thing.
      Besides, in this situation you don't have to have the windows people going in and logging into the unix machines via putty or whatever to see the ncurses version of the monitor.
      Just have them download php-gtk which is practically a plugin at this point and they can create desktop icons or whatever for the app.
      Makes my life easier and theirs and I can crank out apps and debug them fast with how I have it set it up.
      Appropriate is in the eye of the manager in this case.

    4. Re:Slashdot by turnin · · Score: 2, Insightful

      >in-appropriate php apps
      you are correct, BUT, the struggle for existence will force us to take many directions, independent of the appropriateness.
      The struggle here is to find a means to deliver apps on to multiple platforms(OSs).
      Existence of such a means are getting closed, due to *PURE* commercial interests.
      The developers are finding those means for their better life, appropriate or in-appropriate doesn't matter here.

    5. Re:Slashdot by waffle+zero · · Score: 1
      Would it be that much of a intellectual hurdle to switch to Perl, where you can leverage CPAN?

      To accompany the addition of the CLI interface to PHP in 4.3.x, the PEAR repository was created. It is very much CPAN-like with a couple hundred maturing PHP OOP modules. Noteworthy among them is a DB module that provides database abstraction. Installing modules is as easy as

      pear install MODULE
      from the command line.

      Currently you aren't seeing PEAR used much because of its late addition to the 4.x series, but as soon as web hosts move to and embrace PHP 5 there should be a pretty good growth period. The same is true with the CLI interface, but it is taking hold. The m0n0wall FreeBSD router/firewall/packet shaper project uses PHP for system configuration instead of traditional bash shell scripts and C programs.

    6. Re:Slashdot by lscoughlin · · Score: 1

      No, syntactically, they are not the same language. They are very different. Yes, they both use $'s. So do accountants. Thats really about it. PHP is much more rigid, much better defined, and much much easier to read.

      Which isn't to say that perl doesn't have it's place -- it does: one liners written to mangle up some text.

      -T

      --
      Old truckers never die, they just get a new peterbilt
    7. Re:Slashdot by Anonymous Coward · · Score: 0

      Crazy moderators!
      This isn't insightful, it's flamebait by a trollster.

    8. Re:Slashdot by Anonymous Coward · · Score: 0

      With perl, python & ruby targetting parrot and a PHP front end in progress, your dubious argument is soon to be worthless. Find another troll.

  2. Embedding PHP scripts in an EXE by Guspaz · · Score: 4, Interesting

    This is probably a good time to mention EncPHP, a program I wrote that encapsulates a PHP script along with most of what it needs to run inside an EXE. Both console and GUI PHP apps are supported, though for GUI apps, if you choose to embed all of GTK inside the app, it's going to be huge.

    It hasn't been updated in ages, but you can check out the latest version here: EncPHP on SourceForge

    The sourcecode is included... it uses a free BASIC compiler to dynamically compile a dependance-free EXE with the PHP script, PHP interpreter, and required DLLs, inside an EXE. When the EXE is run, it extracts it all and runs the PHP script with the parameters passed on the command line. There are some simple options you can add to the start of your PHP script to tell it to include other files, and if it is a console or GUI app (to show or hide a console).

    1. Re:Embedding PHP scripts in an EXE by unixbum · · Score: 2, Informative
      "When the EXE is run, it extracts it all and runs the PHP script with the parameters passed on the command line. There are some simple options you can add to the start of your PHP script to tell it to include other files, and if it is a console or GUI app (to show or hide a console)."
      So your saying this is basicly a self-extracting archive that executes when run? PriadoBlender (not for production use still in alpha) is a open-source php-compilier/packager that uses the cross-platform PHP Embed API and PECL's bompiler to package the whole shebang in to a execuatable, totally self included and modified to run without conflicts to existing PHP installations. There was a old program (non-opensource) PHPCompilier that did the same thing.
    2. Re:Embedding PHP scripts in an EXE by Guspaz · · Score: 2, Informative

      Pretty much, yeah, it's a glorified self-extracting archive. Of course, you can't acheive the same functionality with WinZIP or WinRAR, as they can't hide the PHP console for GUI apps, or pass command line parameters to the PHP script.

      I'm sure all those programs are vastly superior to mine; Mine was only a kludge designed to fill a specific need to which I could not find a usable solution.

      I should point out that my program, EncPHP, which was released under the LGPL, predates PriadoBlender by over a month; the oldest version in SourceForges archives, the second release, was timestamped "2003-08-07 21:00", with the first release having been finished several days/weeks before then :p

      Anyhow, PriadroBlender looks very promising (Certainly superior to my kludge!), and I'll be interested to see how it turns out.

    3. Re:Embedding PHP scripts in an EXE by Guspaz · · Score: 1

      One small advantage my crappy program has, it runs under Win9x, unlike PriadoBlender :p

      Regardless, portable PHP applications seem to be making progress since I first started messing with it. Soon I might switch over all my Windows development from C# to PHP. All I code is personal projects anyhow.

    4. Re:Embedding PHP scripts in an EXE by HogynCymraeg · · Score: 0

      Maybe this is the answer for cross platform php-gui?

    5. Re:Embedding PHP scripts in an EXE by joeldg · · Score: 1

      What we *REALLY* need is a delphi-like interface for widgets in PHP-GTK.
      Either that or a program to transform exisiting GTK projects (i.e. widgets yadda yadda) into easy use with PHP..
      That gives me some ideas now.

    6. Re:Embedding PHP scripts in an EXE by Guspaz · · Score: 1

      Ideally such a project would be included in a fully-fledged IDE such as Zend Studio. That'd put PHP in line with other such languages.

    7. Re:Embedding PHP scripts in an EXE by Anonymous Coward · · Score: 0
      Maybe this is the answer for cross platform php-gui?

      Warning...this link redirects to a site not safe for work. Goddamn fucking trolls.

  3. I want PHP-Qt dammit! by bergeron76 · · Score: 2

    What ever happened to PHP-Qt? I saw an implementation of it a few years ago, and it's since been stagnant...

    Anyone know what's up with that?

    --
    Don't think that a small group of dedicated individuals can't change the world. It's the only thing that ever has.
    1. Re:I want PHP-Qt dammit! by Crayon+Kid · · Score: 2, Interesting

      I'm gonna venture and say that PHP-Qt is not as attractive as PHP-GTK. The PHP people probably want PHP-GTK to spread as far as possible, or at least cross equally well between Windows and Linux. And Qt has those licensing issues for commercial apps on Windows.

      --
      i ate crayons when i was a kid and now i have two braincells and the blue ones taste nicer
    2. Re:I want PHP-Qt dammit! by LWATCDR · · Score: 1

      QT hass licensing issues for free apps on Windows. commercial apps are not a problem

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
  4. As a sometime PHP user, let me say... by CTachyon · · Score: 1, Funny

    ...NOOOOOOOO!

    As much as PHP might be a decent language for writing server-side web logic, PHP is Perl rewritten by people who don't grok Perl. Unfortunately, I have yet to find a webpage-embedded language that I like enough to replace PHP.

    --
    Range Voting: preference intensity matters
    1. Re:As a sometime PHP user, let me say... by lscoughlin · · Score: 2, Informative

      Or perhaps it's simply another language written by people who do not want to have the issues that perl has, and perhaps want a language that lends itself to knowing what you were doing 15 minutes after you started doing it.

      Go away perl fanboy, or come up with somethingbetter, after all TIMTOWTT (There Is More Then On Way To Troll).

      -T

      --
      Old truckers never die, they just get a new peterbilt
    2. Re:As a sometime PHP user, let me say... by ameoba · · Score: 1

      Face it; PHP is the 'slower' little brother of Perl.

      No language that puts the ENTIRE standard library in the global namespace is suited for actually writing applications. I mean, if you're going to stuff your namespace full of crap, can't you at least make the naming conventions consistant?

      --
      my sig's at the bottom of the page.
    3. Re:As a sometime PHP user, let me say... by Anonymous Coward · · Score: 0

      This is so funny, I can't wait until both Perl and PHP are compiling to the same bytecode and running on parrot. What are you going to find to complain about then?

    4. Re:As a sometime PHP user, let me say... by CTachyon · · Score: 2, Informative

      Or perhaps it's simply another language written by people who do not want to have the issues that perl has, and perhaps want a language that lends itself to knowing what you were doing 15 minutes after you started doing it.

      Oh, come on. On what planet does it make sense to require e.g. generating SWF (Macromedia Flash) files to either be built in to the core language, or excluded altogether requiring a recompile to install that functionality?

      Is adding a use Module; line *really* that much harder for a newbie? He/She still needs to read the documentation anyway to figure out what the available function calls are.

      --
      Range Voting: preference intensity matters
    5. Re:As a sometime PHP user, let me say... by joeldg · · Score: 1

      You have 'NO' idea what you are talking about.
      take a look at http://us2.php.net/manual/en/function.dl.php
      whic h is the function to load a PHP extension at runtime. ...

    6. Re:As a sometime PHP user, let me say... by CTachyon · · Score: 1

      I have 'EVERY' idea what I'm talking about. I've f***ing written loadable modules in C for PHP -- which, BTW, has absolutely no namespace support other than manually naming every function "foo" as "module_foo" (and thus being unable to shorten it by importing the namespace). I've also read the entire PHP manual from start to finish. Don't go telling me that I'm not aware of PHP's language "features".

      --
      Range Voting: preference intensity matters
    7. Re:As a sometime PHP user, let me say... by joeldg · · Score: 1

      From:
      Oh, come on. On what planet does it make sense to require e.g. generating SWF (Macromedia Flash) files to either be built in to the core language, or excluded altogether requiring a recompile to install that functionality?
      Specifically:
      "either be built in to the core language, or excluded altogether requiring a recompile to install that functionality"
      Is a complete untrue statement, I dynamically load modules all the time in code where in places (I.e. dedicated hosting platforms) I do not want to compile it into the "core".
      I stand by my statement.

    8. Re:As a sometime PHP user, let me say... by Anonymous Coward · · Score: 0

      It'd be fitting. They both suck.

    9. Re:As a sometime PHP user, let me say... by CTachyon · · Score: 1

      The extension modules that come with PHP go to extraordinary lengths to keep them from being compiled independently of building a new copy of PHP, even if you're just trying to build them as extensions for an existing PHP. It's not like Perl where you can just do a perl -MCPAN -e 'install Package::Name', or Apache where you can use the APXS tool to easily build outside the Apache tree. It's *possible*, but it's extraordinarily creaky. Plus, it's impossible to install it for only one host in a virtual hosting environment, so the lack of a package namespace means *every* PHP script of *every* host has to be checked for namespace collisions.

      This doesn't even touch on things like the complete lack of a unified SQL database layer like Perl's DBI. Having to rewrite your PHP app from scratch because you switched from MySQL to Postgres is *NOT* a sign of a well-thought-out language.

      --
      Range Voting: preference intensity matters
  5. I made a few updates to that tutorial. by joeldg · · Score: 1

    I added a few things, thoughts etc from people on the NYPHP list and others who have contacted me.
    I added in a few base functions for doing XPM alpha-blending as well as the output from Glade to see how easy it would be to write a Glade->php-gtk parser.

    As for the "perl duuudes" on here, perl is fine for what it is, I use it. However, in this particular instance perl is not an option as I work in a PHP shop and this is actually a project for my work.. On that note however, I 'have' been steadily replacing perl scripts with PHP scripts as they are superior for doing a lot of what I do and working with our established libraries which are not in perl.

    And in response to the "PHP puts everything in global namespace" comment, you obviously have not used PHP in a long time. Or you didn't bother to read through the docs when you installed it.

    Anyway, glad people are liking the tutorial.

    1. Re:I made a few updates to that tutorial. by Anonymous Coward · · Score: 0

      Thanks Joe, great tutorial. Slashdot is still pretty indispensable for the odd random news like this. With even the perlboys getting sick of hearing themselves sound so stupid it seems maybe we are getting back to a point where [please, even] more comments are interesting/insightful.

      Im sure its been said, but: Linux/Perl/Whatever elitists, you embarrass yourselves when you champion hooking a washing machine to a pc just for the simple joy of hacking, only to turn around with your moronic 'right tool for the job' sheep mantra anytime you see the letters php.

    2. Re:I made a few updates to that tutorial. by Anonymous Coward · · Score: 0

      I've used PHP very recently and have even contributed to the documentation for 5.0 (see the php domxml docs.)

      PHP *does* put everything in the global namespace. Right up to 5.0.

      My guess would be that you think otherwise because you have no idea what a namespace is, and think that since you have class-level and function-level variable declarations that those somehow provide "namespaces."

      (They don't.)

  6. Tahya al-Moqawama al-Iraqiya! by Moqawama · · Score: 1

    Tahya al-Moqawama al-Iraqiya!
    Fuck the American imperialists!
    Death to them all!!