PHP CLI and PHP GTK
If you are using both PHP CLI and PHP GTK on the same desktop machine, you may run into certain errors if you launch PHP CLI program from command line logged as another user.
PHP Fatal error: php-gtk: Could not open display in Unknown on line 0
Could not startup.
If you have logged in as one user, you cannot run standard PHP CLI commands as another user from command shell because that user has no access to your desktop environment. If you have to test php scripts which are designed to be used by other users, then you can solve this very easily. Make a copy of /etc/php5/cli
sudo mkdir /etc/php5/cli_gtk
sudo cp /etc/php5/cli/php.ini /etc/php5/cli_gtk/
sudo ln -s /etc/php5/conf.d /etc/php5/cli/conf.d
Now remove from /etc/php5/cli/php.ini those dynamic extension lines for php_gtk and cairo, and same the file. When you run standard PHP CLI, you can launch them with
But when you want to run PHP GTK programs, you can launch them with
php -c /etc/php5/cli_gtk/ myprogram.php
extra parameter tells php interpreter to use php.ini in directory /etc/php5/cli_gtk.