I'm doing PHP development and I'm thinking of using one of these. I have both PHP and Java installed on my machine. In theory I could use any of the two.
What are the compelling arguments to pick Phing over Ant?
The greatest argument I have in favor of Phing is that it's fully developed in PHP ; which means, at least :
You can debug it / submit patches if you want
You can develop tasks in PHP
including tasks which are specific to your project
that can use stuff from your project (I've written a couple of tasks that use functions of Drupal, in a drupal-based project)
And, if you are working on a PHP project, your team probably knows PHP well -- while they might not know Java
No need to install Java on your servers
The main argument (for me) for using Phing when doing PHP development is
staying inside the PHP Ecosystem.
When using Phing on shared hosts, you can be sure it works when PHP works.
And you can easily extend Phing with your own task in PHP.
And since it's a PHP tool you will sometimes find it in other applications as well.
Related
Is there a good, simple solution for PHP "one-click" deployment to a production server? And also with a functionality to reverse back if needed.
In particular, I am interested in this with regards the PHP code itself. But if you know a good solution for MySQL, it is also welcome.
For deploying easily, we use Capistrano (its a Ruby tool, but deploys anything really) and its great, just need
cap deploy
from the command line (at its simplest)
If you want something written in PHP I can't name any I'm afraid.
For MySQL, I guess you would need some kind of migration tool, or build your db changes into SQL files that can be run by your deployment script.
I have developed a PHP web application, but a client insists on a real Windows application, since he doesn't like running the software inside a browser.
Are there any solutions for this, any compilers to turn a web project into a Windows exe ?
I have looked at Phc-Win , but that seems more suited for small command line utils, not for entire web-applications...
UPDATE:
just found this myself, both look quite promising...
http://www.zzee.com/phpexe/
http://www.exeoutput.com/index.php
There's no tool for this, short of a simple wrapper app that embeds a browser inside an otherwise normal application window. Your PHP app would have to be completely re-written to include ALL of the overhead code necessary to build a GUI - basically all the 'display' stuff that a browser does automatically, would have to added to your app.
Well some of you did not google good enough:
http://www.appcelerator.com/products/titanium-cross-platform-application-development/
Supports most of the "web-languages" to write native Applications.
Tutorial Reference for Appcelerator: http://appceleratortitanium.com/tutorials/3-appcelerator-titanium-tutorial-beginners.html
Quote:
"Q: What languages can I use to make desktop apps?
A: Javascript, PHP, Python, Ruby, HTML, HTML5, and CSS."
Not exactly what you are looking for: http://www.roadsend.co/home/index.php?pageID=compiler
You may look into "HipHop" (made by Facebook): Converts PHP to compileable C++-
There's a tool for this. :-) I never used it but you can try this: Winbinder.
It is simple to compile your PHP source code into an executable. Facebook released a compiler for PHP in early-2010, called HipHop, which aims to create C++. You could then compile this code, for example using gcc, to machine-code.
The more difficult point for a complex Web-App like yours is the user interface. When compiling the way I described above, the application can be run from command line - this might work for simple tasks, but not, if your application returns HTML.
One possibility to solve this problem is PHP-GTK. PHP-GTK is a API for GTK (the graphical user interface used by Linux Ubuntu by default), written in PHP. Using this solution would have to read some documentation about this API, and you would need to rewrite some parts of your program, but it would probably be the most beautiful solution, because it would create a "native" experience.
Another possible solution could involve Adobe AIR, which lets your create programs for the desktop, using HTML, CSS and JavaScript, but I don't know if and how this would work together with your compiled PHP.
Please also note that it isn't absolutely necessary to compile your PHP for it to run on the client's computer; You could also ship the PHP-interperter right with your (uncompiled) PHP-script. Of course, compiling brings benefits, such as faster execution of the program.
-- André
I want to program a little CLI script in PHP, basically with two possible arguments to do two different things. Very easy. But I would like to do in an elegant way.
I was wondering if it exists some PHP micro-framework functionaly in CLI mode (note that I say micro-framework and not framework). I want to use PHP because I'll include some PHP already programmed classes.
I have found CLImax, that is an specific CLI micro-framework and seems good, but it lacks a good documentation.
Do you know any place where I can found a good CLImax documentation (I haven't found anything, but its source code poorly documented)?
Or maybe do you know another option? Alloy seems as well a lightweight PHP framework, and has CLI "mode", but I don't know if it's too generic, as it's as well for web servers. Have you used it?
Check out the Symfony Console component. Here's an introduction to using it. It may take a little bit of work to get it to function with an older version of PHP (without namespaces), and you need a couple other components from Symfony, but I've used it quite successfully.
I've found this one: php-cli-tools
It's definitely micro and brings everything you'd have with sh or windows batch.
It doesn't have great documentation from what I can see, but Cilex describes itself as:-
"a lightweight framework for creating PHP CLI scripts inspired by Silex"
Might be worth a look, I am thinking of using it myself to replace the bash deployment scripts I have written.
Laravel has a command line tool called Artisan which it allows you to extend quite easily;
Artisan is the name of the command-line interface included with Laravel.... [Artisan Development] In addition to the commands provided with Artisan, you may also build your own custom commands for working with your application.
See the documentation for Artisan development here
Check out https://github.com/c9s/CLIFramework
CLIFramework is a full-stack framework for command-line tools, unlike Symfony/Console, it has a concise API for building lightweight command-line application.
It allows you to define few options and argument info to generate a help document rapidly.
The most important part is that CLIFramework can generate zsh completion script automatically, so you don't need to write zsh script for every command line application.
You might be interested in my php cli framework: https://github.com/b-b3rn4rd/Terminalor
Terminalor - is a php library for creating portable php cli files. It provides essential functionality to work under cli interface and can be used as a wrapper for external libraries. It allows rapidly create documented cli commands with arguments using closures and phpdoc comments. Later this commands can be compiled into single independent portable file.
I don' think many of the suggestions above are micro-frameworks - even though many of the suggestions are great frameworks - and properbly better in many use-cases than my suggestion: https://github.com/diversen/minimal-cli-framework
It is much faster than the above frameworks (though it is rare that you need speed from a CLI-framework). It lets you add sub-commands using class objects. It generates help and command-definitions from a single method. You will only need to implement two methods to an existing class to use it with the minimal-cli-framework (getCommand - definition of the command and runCommand - the execution of the command).
Disclaminer: I wrote the package.
Did you try Seagull? It looks like it too natively supports projects that are specifically meant to be used in the CLI.
For my web application running on LAMP, I need to be able to deploy database migrations and code changes on multiple servers and be able to test deployment afterwards, all of this automatically done by scripts.
Currently I'm torn between using directly my build tool (Phing) with some special deployment/test tasks, or shell scripts, or a scripting language like Ruby or Python.
The problem is that I feel that a build tool should be used to build, not to deploy. I also feel that shell scripts are hard to maintain and not very readable.
Do you have any good advice on this subject ?
For PHP projects, Phing is the way to go. Deployment is definitely one of its intended usage, considering that in PHP there isn't any "real" build process - as scripts are not compiled.
From the official site:
If you find yourself writing custom
scripts to handle the packaging,
deploying, or testing of your
applications, then we suggest looking
at the Phing framework.
Phing can do everything shell/python/ruby scripts can do, and can be extended in PHP which is its major draw for PHP developers. Why would you want to use ruby/python if you are a PHP developer?
Rasmus Lerdorf (creator of PHP) released a deployment tool called WePloy.
A lot of people here on stackoverflow seem to really like Capistrano.
To deploy web applications, PHP or other, in some click, you can use fredistrano.
What have I used?
svn post-commit hook
shell script to rsync
perl cgi script to svn switch across systems
It doesn't seem like any of these would be acceptable for you though, given your statement "I also feel that shell scripts are hard to maintain and not very readable."
Personal script which uses
Svn export + rsync
We currently use a hand-rolled setup and configuration script and a hand-rolled continuous integration script to build and deploy our application. I am looking at formalizing this somewhat with a third party system designed for these purposes.
I have looked into Phing before, and I get that it's basically like Ant. But, my Ant experience is somewhat limited so that doesn't help me much. (Most of the Java work I have done was just deployed as a jar file).
I have looked into Cruise Control before, and I understand that phpUnderControl is a plug-in for CC. But, Phing says it also works with CC. So I am not clear on the overlap here. Do I need both Phing and phpUnderControl to work with CruiseControl, or are they mutually exlclusive?
What I need exactly is something that can:
Check out source from SVN
Install the database from SQL file
Generate some local configuration files from a series of templates and an ini file
Run all of our unit tests (currently ST, but easy to convert to PHPUnit) and send an email to the dev team if any tests break (with a stack trace of course)
Generate API documentation for the application and put it somewhere
Run a test coverage report
Now, we have just about all of this in one form or another. But, it'd be nice to have it all automated and bundled together in one process.
phing is pretty much ant written in PHP where phpUnderControl adds support for PHP projects to CruiseControl and uses phing or ant on the backend to parse the build.xml file and run commands.
I just set up CruiseControl and phpUnderControl and it's been working great. It checks out my SVN, runs it through phpDocumentor, PHP_CodeSniffer, and PHPUnit whenever we do a check in. Since it's all based off of the build.xml file you can run just about any software you want through it.
I'm sure lots of people will say this by the time I've typed this but...
I know it's not PHP but we're finding Capistrano just the job for this kind of thing. It really is an excellent piece of software.
We've been using Phing, and the cost to set it up has been very low; it's really easy to learn even if you don't know ANT. I've had very bad experiences with CruiseControl (instability - going down randomly) - so I like the simplicity of Phing. Plus, it's easily extensible using PHP (in case you have a custom task that they don't support out of the box).