On 1/7/11 11:08 AM, Nicholas Kell wrote:

On Jan 7, 2011, at 11:01 AM, Joshua Kehn wrote:

On Jan 7, 2011, at 11:55 AM, la...@garfieldtech.com wrote:

Hi folks.  I have a project coming up that will involve writing a non-trivial 
command line PHP application.  Most of it will be nice and abstracted and 
standalone and all of that jazz, but it will need to do command line 
interation.  I'm not sure yet if it will be interactive or if I just need to 
parse lots of command line switches.

Has anyone used a CLI-handling library they like?  I recall briefly using the 
PEAR CLI library many many years ago and disliking it because it was only 
barely a step above the raw PHP-CLI SAPI, and still required lots of if-else 
branching in my code.  I don't know if there's anything better since then, 
however.  I prefer clean OO to procedural, but can work with procedural if 
needs be.  The fewer dependencies it has the better as well.

Any recommendations?

(Open source, GPLv2-compatible required.)

--Larry Garfield

Larry-

Why are you writing a command line application in PHP? I would think that is 
starting off on a very wrong foot.

Can you explain the requirements / use cases a bit more?


I agree. Not saying that it isn't doable, because it certainly is, but there 
may be other languages that are available and easier to implement a CLI app, 
such as Python, or some other QnD scripting language.

"Application" is perhaps a misnomer. I'm not looking at rewriting Emacs or anything. Just some batch processing that would get run as:

php myscript.php --config=foo.xml --setting-1=stuff

And then it will run off and move a few million records around between different data stores, a process that will probably take an hour or so. (The backend will be cycling through a queue server.) I just need something to make handling of the args and environment easier, because I find the native SAPI calls to be ugly/cumbersome.

I'm sure it could be written in Perl or Python or Java. But I know extremely little Perl, no Python, and my Java is quite rusty, plus there are mature PHP libraries that talk to the 3rd party systems I'm tying together. My PHP-fu is much stronger than my Perl, Python, and Java combined.

<OT>
Yeah, PHP was "intended" as a template language only; that fell by the wayside a decade ago or more when people started building real web apps in it, which are a lot more than templates. That boat has long since sailed and is irrelevant to this discussion.
</OT>

--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to