I have a php project I'm working on using PhpStorm. I have a python script which manipulates my css file in a certain way before uploading it to the server (it's irrelevant to the question, but if you're curious, mostly related to language support).
I'd love to be able to run it directly from phpstorm, but I'm unsure how to do it (I'm guessing it's possible but I couldn't find any reference to something of the sort, and I'm kinda new to this IDE). I know I can rewrite the script with php but I'd rather not (I'm still a pythonist at heart).
Anyone had to tackle something of the sort?
Thanks in advance!
p.s. I'm running Ubuntu if that matters.
Use File Watcher plugin for that (should be bundled since v7 by default) -- this way such script will be run on each of desired modified files on save automatically.
http://confluence.jetbrains.com/display/PhpStorm/File+Watchers+in+PhpStorm
Alternatively you can use External Tools functionality and invoke it manually when desired.
http://www.jetbrains.com/phpstorm/webhelp/external-tools.html
According to the help page you can run scripts in the "Before launch". IMHO you can configure an external tool to be your python script (change +x to make it executable...).
Alternatively, I think you could install the python plugin (I've never tried it).
I'm trying to make sense on the best way to do automatize a series of things in a row in order to deploy a web-app and haven't yet came up with a suitable solution. I would like to:
use google's compiler.jar to minify my JS
use yahoo's yui-compressor.jar to minify my CSS
access a file and change a string so that header files like "global.css?v=21" get served the correct version
deploy the app (sftp, mercurial or rsync?) omitting certain directories like "/userfiles"
Can you guys put me on the right track to solve this?
Thank you!
you may want to check out phing http://phing.info/ (they are in the process of moving servers so may be down this weekend), but it can do all of what you are wanting and is written in php.
A quick google search should bring up plenty of tutorials to get you started.
You can run php from the command line to do all sorts of fun things.
$ php script_name.php arg1 arg2
See: command line, argv, argc, exec
Running PHP from the command line is very fast. I've been doing this a lot lately for various automation tasks.
I generally run Python projects so this may or may not be an option for you: but apart from writing your own scripts you could look into the following:
Fabric
Buildout
maven
I am working on a ZF application that needs to run a command line script and then parse the results into something meaningful and return to the user.
I know there are various PHP functions, like exec and system, but I was wondering if there is anything built into Zend Framework that does command line scripting easily.
Even if there isn't a ZF specific function, what is the best function/method to use for running a command line script and then retrieving the results in PHP upon completion of the script.
I would write a Service which uses exec to get what you need. You can add some basic error handling there.
You can start an process under linux with this:
ZendX_Console_Process_Unix
But never tryed it..
We recently needed to do this (we use ZF too), hope this helps: http://www.kintek.com.au/web-design-blog/how-to-run-a-php-script-from-command-line/
I'm trying to make sense on the best way to do automatize a series of things in a row in order to deploy a web-app and haven't yet came up with a suitable solution. I would like to:
use google's compiler.jar to minify my JS
use yahoo's yui-compressor.jar to minify my CSS
access a file and change a string so that header files like "global.css?v=21" get served the correct version
deploy the app (sftp, mercurial or rsync?) omitting certain directories like "/userfiles"
Can you guys put me on the right track to solve this?
Thank you!
you may want to check out phing http://phing.info/ (they are in the process of moving servers so may be down this weekend), but it can do all of what you are wanting and is written in php.
A quick google search should bring up plenty of tutorials to get you started.
You can run php from the command line to do all sorts of fun things.
$ php script_name.php arg1 arg2
See: command line, argv, argc, exec
Running PHP from the command line is very fast. I've been doing this a lot lately for various automation tasks.
I generally run Python projects so this may or may not be an option for you: but apart from writing your own scripts you could look into the following:
Fabric
Buildout
maven
Is there a simple "Web interface" to running PHPUnit test suites? i.e. a PHP script that runs the test on the command line, and outputs a nicely formatted HTML result.
I develop web applications, and the day-to-day workflow usually switches between the IDE and the browser. I would like to have the unit testing in the same environment.
I'm looking for something really simple and PHP based - I am planning to get into phpUnderControl (which has the functionality I'm looking for) but not yet.
I recently discovered Visual PHPUnit which looks like a very very nice interface for everyone that doesn't want to run PHPUnit from the command line:
It seems to be the next iteration of #Matt's PHPUnit Test Report
I feel your frustration - I'm a UI guy myself. Looking at the terminal too long makes my head spin. I wrote a quick little application that you might find helpful.
(source: mattmueller.me)
You can find it here: http://mattmueller.me/blog/introducing-phpunit-test-report
Cheers!
Matt
After several hours of researching recently, the best PHPUnit web frontend I have come across was https://github.com/NSinopoli/VisualPHPUnit
You can use phing to run a PHPUnitTask and then convert the output with:
PHPUnitReport - This task transforms PHPUnit xml reports to HTML using XSLT.
Example:
<phpunitreport infile="reports/testsuites.xml"
format="frames"
todir="reports/tests"
styledir="/home/phing/etc"/>
See phpunit --help for the various output formats.
The 2.3 version of PHPUnit had a chapter on this, but it is gone for some time now. You might be able to find an old copy with Google somewhere.
Since you mention this is for phpUnderControl: if you are not fixed on that, consider using Jenkins and http://jenkins-php.org.
On a side note: unless we are talking CI servers, most people I know don't use PHPUnit through a web interface. They either just use the command line or their IDE integration.
You can use Jenkins to run any kind of tasks including PHPUnit tests. It can automatically checkout your app, run the tests, build a HTML report and even email you if the build fails.
Here's the templates you need to setup Jenkins to build a bunch of interesting reports and stats from your project.
If you don't care about reformatting the output and just want to run PHPUnit from a web page, you can do so with some PHP code like this:
<pre>
<?php
$argv[0] = "phpunit.phar";
$argv[1] = '--bootstrap';
$argv[2] = 'src/load.php';
$argv[3] = "tests/MoneyTest";
$_SERVER['argv'] = $argv;
include 'phpunit.phar';
?>
</pre>
The file src/load.php is just a bunch of includes to include the classes. The output then looks like this:
#!/usr/bin/env php
PHPUnit 4.1.2 by Sebastian Bergmann.
........................
Time: 122 ms, Memory: 3.25Mb
OK (24 tests, 43 assertions)
Just ignore that first line and you can see the results.
I'm shocked that PHPUnit does not include a basic way to do this. Some classes may be dependent on the web server. Do we just not test those? Some sites have you upload your files and don't allow command line executions.
I've never seen such a web-interface... But, as you say you are always using your IDE and your webbrowser, why not think the other way ?
i.e. a possible solution would be to launch the unittests from your IDE ;-)
Which means you should be able to click on the failing tests to "jump" to either the test method, or the reason that caused the test to fail, for instance.
In the PHP + PHPUnit world, I know that Zend Studio does that -- yes, it's not free, unfortunatly ;-(
Using Eclipse PDT, a solution would be to register PHPUnit as an external tool (see or instance this blogpost : Using PHPUnit with Eclipse PDT) -- but it's quite not sexy, and you cannot click on the results to jump the the methods/tests...
Another solution would be to develop a plugin to integrate PHPUnit into Eclipse PDT (like it's been done for Zend Studio, I suppose) -- A phpunit4eclipse was created some time ago, but it's just a start, and didn't get much succes, so the author didn't work on it after releasing that...
I found this:
I stumbeld upon a post from Parth Patil, whose solution was to create an xml-report from PHPUnit and then use this xml to create your own report.
I used his solution, made it PHPUnit 3.4 compatible and also added some Reflection to see my testcase doc-comments in the report. (Note: For the refelection i use the Zend_Framework reflection class)
Ok you said you'd prefer an independent IDE solution, but just so you know there is a recent plugin that enables executing PHPUnit simply into Eclipse, and having a nice representation (like in Zend Studio, but for free).
Here is the link, the main developper replies fast to emails too if you have a problem :
http://www.phpsrc.org/wiki/
I personnaly tested some web interface, but I have always been deceived (not really practital and stable). But this is your choice.
jframework also has a nice UI for PHPUnit. It breaks the results, and shows test coverage on all files and each file separately.
It works on both web and cli, with the cli one having the benefit of dumping every test after its done (the web-based one has to wait until everything is over).
You can always use the Maven for PHP from which you can use the surefire reports (mvn site).
More info here: http://www.php-maven.org