Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

  1. #1
    Join Date
    Apr 2008
    Beans
    82
    Distro
    Ubuntu 12.04 Precise Pangolin

    HOWTO: How to install PHP-GTK in 10.04 Lucid Lynx and Ubuntu 10.10 Maverick Meerkat

    Just tested, this works on Ubuntu 10.10 Maverick Meerkat as well.

    I have had to Google search to be able to install PHP-GTK completely, and I'm going to correlate everything into this how-to here. Hope it helps.

    First, we need to install all the prerequisites to installing PHP-GTK:

    Code:
    sudo apt-get install build-essential subversion php5-cli php5-dev libgtk2.0-dev libglade2-dev
    Then we need to get the Cairo PHP extension (required to install PHP-GTK):

    Code:
    cd ~/Downloads
    svn co http://svn.php.net/repository/pecl/cairo/trunk pecl-cairo
    cd pecl-cairo
    phpize
    ./configure
    make
    sudo make install
    Then we need to do the following step in order for the ./buildconf and ./configure commands to work when we're at the stage of installing PHP-GTK, the reason is (according to others), the newer libtool.m4 has been split into different files. To make PHP-GTK ./buildconf and ./configure to work (and subsequently get PHP-GTK installed), we need to concatenate the different files back into the libtool.

    Code:
    cd /usr/share/aclocal
    sudo cp libtool.m4 libtool.m4~backup
    sudo chmod 777 libtool.m4
    (start line) sudo cat lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 >>libtool.m4 (end line)
    sudo chmod 644 libtool.m4
    You're almost there. However, we need to get the latest SVN version of PHP-GTK - if you get PHP-GTK source from PHP-GTK website, you will get an error similar to this:

    error: duplicate ‘static’

    ...when running the make command. In PHP-GTK 2.0.1, this macro expands simply to “static”. This was because the ZEND_BEGIN_ARG_INFO() macros at the time didn’t mark the variables as static. This was introduced in 5.2.9. So it stands that if you compile PHP-GTK 2.0.1 against PHP 5.2.9 or later, you will get that duplicate static error. In the SVN repoistory, this was fixed. (thanks: http://devlog.mahcuz.com/2010/08/php...licate-static/)

    To counter this problem, we obviously get the latest SVN version:

    Code:
    cd ~/Downloads
    svn co http://svn.php.net/repository/gtk/php-gtk/trunk php-gtk
    cd php-gtk
    ./buildconf
    ./configure
    make
    sudo make install
    Once we've done that - we need to do a few more things (although, PHP-GTK is now installed ).

    In Ubuntu 10.04, /etc/php5/cli/conf.d/ and /etc/php5/apache2/conf.d/ are symlinks to /etc/php5/conf.d/, so we need to fix that:

    Code:
    sudo rm /etc/php5/cli/conf.d
    sudo mkdir /etc/php5/cli/conf.d
    sudo cp /etc/php5/conf.d/*.ini /etc/php5/cli/conf.d/
    Now we need to add the PHP-GTK and Cairo extensions to the php.ini file for PHP to recognise them: run php-config and find (near the start) the extension_dir line. It may say something like (or exactly like) this:

    Code:
    --extension-dir     [/usr/lib/php5/20090626+lfs]
    That's where your PHP-GTK and Cairo files are that php.ini need to know about.

    To find where your php.ini file is, go to Places -> Computer then select File System from the left. Click Go->Search For Files and search for your php.ini file. You may find two. Open each one and in gedit, look at application title bar and you'll see where the php.ini file is from. If it's in a cli directory, that's the one you need to add the extensions line in. Close it, bring the Terminal window back up and type:

    Code:
    sudo gedit /etc/php5/cli/php.ini
    (modify to where your php.ini file is, if applicable)

    Press CTRL + F and type Dynamic Extensions, you'll see a list of information about extensions and "commands" but with semi-colons at the start of them - these are comments. Just above where it says "Module Settings" wrapped around semi-colons, add the following;

    Code:
    extension=php_gtk2.so
    extension=cairo.so
    This tells PHP what these files are called for PHP-GTK and Cairo within the extension_dir it's already aware of.

    Once done, now it's time to test the PHP-GTK installation. Back in Terminal, type: php ~/Downloads/php-gtk/demos/phpgtk2-demo.php and a PHP-GTK application should load up.

    If you have any problems, feel free to post. I'm sure someone will help .
    Last edited by bastones; October 6th, 2010 at 06:57 PM.

  2. #2
    Join Date
    Aug 2010
    Beans
    10

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    This post works perfectly.

    Note that if you try "make test", all the tests will fail, however the installed binary works fine on my system.

    You can test a bit after the full install by saving the following lines in a file called hello.php then running "php ./hello.php".

    <?php
    if (!class_exists('gtk')) {
    die("Please load the php-gtk2 module in your php.ini\r\n");
    }

    $wnd = new GtkWindow();
    $wnd->set_title('Hello world');
    $wnd->connect_simple('destroy', array('gtk', 'main_quit'));

    $lblHello = new GtkLabel("Just wanted to say\r\n'Hello world!'");
    $wnd->add($lblHello);

    $wnd->show_all();
    Gtk::main();
    ?>

  3. #3
    Join Date
    Jan 2009
    Beans
    1

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Thank you very much bastones!!
    This post is just perfect!

  4. #4
    Join Date
    Sep 2010
    Beans
    1

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Thank you, bastones, you're a hero. I solely registered in order to tell you this.

    Tried to run Phoronix Test Suite and couldn't get the GUI working because PHP-GTK wasn't installed on my Ubuntu 10.04. The Phoronix site wasn't any help at all, so I was lucky to find your tutorial. I followed it from A to Z and what can I say? Despite my being a Linux n00b, it just worked, as does the Phoronix GUI. Beautiful.

    Thanks again.

  5. #5
    Join Date
    Sep 2010
    Beans
    1

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Bastones. It is a very useful tutorial. Thanks to you PHP-GTK is running perfect in my Ubuntu. Last night, I installed PHP-GTK in windows vista. Naturally is easier in Windows.

  6. #6
    Join Date
    Apr 2008
    Beans
    82
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Quote Originally Posted by acovaleda View Post
    Bastones. It is a very useful tutorial. Thanks to you PHP-GTK is running perfect in my Ubuntu. Last night, I installed PHP-GTK in windows vista. Naturally is easier in Windows.
    It is so much easier to do this via Windows due to the precompiled binaries available for Windows systems, and you can easily just have a command line script that executes the PHP-GTK file under the php_win.exe file and it'll run just like a usual GUI application. On Linux and Mac OS X you could probably do similar but you would have to rely that they have PHP-GTK installed, etc.

    I'm glad I have helped you guys and I'm surprised I was even able to figure this all out myself...I'm not too much into the Terminal myself . However some other guy from the PHP-GTK IRC channel in FreeNode was able to partly help find out the make command problem. Unlike some other IRC channels the people in #phpgtk were helpful and courteous .

    I am going to install Ubuntu 10.10 in a virtual machine on my computer and test whether the instructions I have given works line by line. Will update this thread over the next few days .
    Last edited by bastones; September 30th, 2010 at 11:29 PM.

  7. #7
    Join Date
    Nov 2007
    Beans
    4

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Quote Originally Posted by bastones View Post
    It is so much easier to do this via Windows due to the precompiled binaries available for Windows systems, and you can easily just have a command line script that executes the PHP-GTK file under the php_win.exe file and it'll run just like a usual GUI application. On Linux and Mac OS X you could probably do similar but you would have to rely that they have PHP-GTK installed, etc.
    Actually I find running the programs even easier in Linux/OS-X as you can just put this as the first line:

    #! /usr/bin/php

    and set the file executable.

    How nice it would be if php-gtk was part of the standard repository for Ubuntu.

  8. #8
    Join Date
    Apr 2008
    Beans
    82
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Quote Originally Posted by cfriisha View Post
    Actually I find running the programs even easier in Linux/OS-X as you can just put this as the first line:

    #! /usr/bin/php

    and set the file executable.

    How nice it would be if php-gtk was part of the standard repository for Ubuntu.
    Ah, I actually forgot about that! So I guess it's as easy on Windows and Mac/Linux then . I heard you can also archive PHP-GTK programs into PHP PHAR archives but I'm not sure whether they'd run like executables on Linux/Mac (i.e. you double click it and it runs through PHP straight away with no extra work needed).
    Last edited by bastones; October 16th, 2010 at 08:33 PM.

  9. #9
    Join Date
    Apr 2008
    Beans
    82
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: How to install PHP-GTK in Ubuntu 10.04 Lucid Lynx

    Just tested on Ubuntu 10.10, same instructions apply and works on Ubuntu 10.10 Maverick Meerkat .

  10. #10
    Join Date
    Feb 2010
    Beans
    103
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: HOWTO: How to install PHP-GTK in 10.04 Lucid Lynx and Ubuntu 10.10 Maverick Meerk

    Bastones, thank you so much.

Page 1 of 4 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •