Posts tagged ·



Open files from the command line in PHPStorm

1 comment

I’m a big terminal fan, and I’m also a PHP developer.  Last month, I switched from Netbeans to PHPStorm for a full-fledged PHP IDE1.  Often, I’m in the terminal, and find it natural to open a file in PHPStorm from there.  Awkwardly, you need to use the full path of the file to do this.  That means, if I’m in /var/www/some_client/some_site/htdocs/resources/web/ I have to type this command just to open index.php in that directory:

phpstorm /var/www/some_client/some_site/htdocs/resources/web/index.php

Ugh. Far too much typing. I looked for a shell integration plugin, or a setting under File -> Settings, where PHP Storm crams thousands of options.2

It turns out, I was just looking in the wrong place. You have to set up this feature, but it’s dead simple. Open Tools -> Create Command-Line Launcher….

PHP Storm Command Line setup menu option

Next, pick a name for the executable and a path to place the shortcut in.  The name is the command you’ll type to run phpstorm from the terminal, so you can make it shorter for even less typing!  The path should be in your system shell’s $PATH variable; PHPStorm’s default is probably what you want if you don’t know what this means.

PHP Storm Command Line Config dialog

PHP Storm Command Line Config dialog

Hit OK to save.  If your user doesn’t have acces to that Path, you may be prompted to enter a password for the system root user.

Once you’re done, you can navigate into any directory and run your command to open files directly in PHP Storm.

pstorm somefile.php

Your life will be 30% better from now on.

  1. mostly on account of IdeaVIM’s excellent VIM emulation.  It’s not complete, but netbeans’ version is vastly inferior.
  2. For a while, I resorted to a slightly shorter workaround, typing “phpstorm `pwd`/index.php” in these situations… still too much typing

downgrade PHP from 5.4 to 5.3 on ubuntu 12.10 quantal quetzal

1 comment

If you’re anything like me, you were looking forward to the release of ubuntu 12.10 (and PHP 5.4).

Perhaps you got so excited that you upgraded all your installations, only to find some of your php applications weren’t quite ready yet.  Bummer.

Luckily, you can downgrade PHP without downgrading Ubuntu.  Because PHP 5.3 is no longer in the ubuntu repositories for quantal quetzal, it’s a bit trickier.  Don’t worry, though, your friends on the ubuntu forums have made it easier.  Emil Terziev has adapted a script by Ruben Barkow to add the old php repositories, uninstall php and related tools, then reinstall the prior versions.

# Original for 5.3 by Ruben Barkow (rubo77)
# release 1 PHP5.4 to 5.3 by Emil Terziev ( foxy ) Bulgaria

# Originally Posted by Bachstelze
# OK, here's how to do the Apt magic to get PHP packages from the precise repositories:

echo "Am I root?  "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
echo "  NO!

Error: You must be root to run this script.
sudo su
exit 1
echo "  OK";

#install aptitude before, if you don`t have it:
apt-get update
apt-get install aptitude
# or if you prefer apt-get use:
# alias aptitude='apt-get'

# finish all apt-problems:
aptitude update
aptitude -f install
#apt-get -f install

# remove all your existing PHP packages. You can list them with dpkg -l| grep php
PHPLIST=$(for i in $(dpkg -l | grep php|awk '{ print $2 }' ); do echo $i; done)
echo these pachets will be removed: $PHPLIST
# you need not to purge, if you have upgraded from precise:
aptitude remove $PHPLIST
# on a fresh install, you need purge:
# aptitude remove --purge $PHPLIST

#Create a file each in /etc/apt/preferences.d like this (call it for example /etc/apt/preferences.d/php5_2);
#Package: php5
#Pin: release a=precise
#Pin-Priority: 991
#The big problem is that wildcards don't work, so you will need one such stanza for each PHP package you want to pull from precise:

echo ''>/etc/apt/preferences.d/php5_3
for i in $PHPLIST ; do echo "Package: $i
Pin: release a=precise
Pin-Priority: 991
">>/etc/apt/preferences.d/php5_3; done

echo "# needed sources vor php5.3:
deb precise main restricted
deb-src precise main restricted

deb precise-updates main restricted
deb-src precise-updates main restricted

deb precise universe
deb-src precise universe
deb precise-updates universe
deb-src precise-updates universe

deb precise multiverse
deb-src precise multiverse
deb precise-updates multiverse
deb-src precise-updates multiverse
deb-src natty-backports main restricted universe multiverse

deb precise-security main restricted
deb-src precise-security main restricted
deb precise-security universe
deb-src precise-security universe
deb precise-security multiverse
deb-src precise-security multiverse

deb-src natty partner

deb precise main
deb-src precise main

deb precise-backports main restricted universe multiverse
deb-src precise-backports main restricted universe multiverse

deb precise partner
deb-src precise partner

" >> /etc/apt/sources.list.d/precise.list

aptitude update

apache2ctl restart

echo install new from precise:
aptitude -t precise install $PHPLIST

# at the end retry the modul libapache2-mod-php5 in case it didn't work the first time:
aptitude -t precise install libapache2-mod-php5

apache2ctl restart

Save the above code as or download the original file from this thread:

To run the script, open a terminal where you saved it, and run the following

chmod +x;
sudo ./

Keep in mind that this will uninstall your new version of PHP and restart the apache webserver. Enjoy your freshly old version of PHP, and upgrade your code so you can run PHP 5.4 as soon as possible!