I’ve spent countless hours trying to find out if cairo.php can be installed on rocky 9.
It does not seem so but I cannot confirm it.
Thought I should ask here in case there is a way.
I need cairo.php but have yet to find a way of installing it.
It would save me countless more hours if someone could confirm this cannot be done or share a url/info on how it can be done :).
There’s also a python3 binding.
Interaction with php wiill usually be done via “extensions”, but it worth checking the rest of the composer.json file to understand what’s it’s trying to do, and if it makes sense.
Hi, well that’s quite different than what I thought I was being told. Thank you.
There must be something I’m missing then.
When I installed composer, it didn’t create a composer.json file so I created one.
This is all I have in it.
{
"require": {
"cairo-php/cairo-php": "@dev"
}
}
The error I’m getting is;
Fatal error: Uncaught Error: Class “CairoImageSurface” not found in /var/www/html/index.php:6 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 6
In the php page code (I added line numbers);
1 <?php
2 error_reporting(E_ALL);
3 ini_set('display_errors', 1);
4
5 // Load the Cairo library
6 $cairo = new CairoImageSurface(CairoFormat::ARGB32, 500, 500);
7 $ctx = new CairoContext($cairo);
And this is what happens when I try to install it.
# composer require cairo-php/cairo-php
In PackageDiscoveryTrait.php line 368:
Could not find a matching version of package cairo-php/cairo-php. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable).
Thanks for your input.
I didn’t know it was already built into the base system.
I tried installing it and based on what you said might be why I saw this error then.
# composer require cairo-php/cairo-php
In PackageDiscoveryTrait.php line 368:
Could not find a matching version of package cairo-php/cairo-php. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (stable).
When I installed composer.json, it didn’t create the file so I created one.
{
"require": {
"cairo-php/cairo-php": "@dev"
}
}
The error I get when trying to run the php page is;
Fatal error: Uncaught Error: Class "CairoImageSurface" not found in /var/www/html/index.php:6 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 6
The first few lines of the page are;
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Load the Cairo library
$cairo = new CairoImageSurface(CairoFormat::ARGB32, 500, 500);
$ctx = new CairoContext($cairo);
I’m sorry, this is getting a bit beyond my knowledge. Is cairo built into rocky, is it something I need to install? Do I need to install it from a third party repo?
I’ve had zero luck trying to find information on this and was hoping posting might help
@CrockyDock As was mentioned, it’s old, it’s not provided by anyone. It’s as remi said, a dead project for PHP 5.x which is unsupported for a long time now. Composer is unlikely to find it unless you are using PHP 5.x anyway. That is why it says it cannot find a version for it.
The prudent alternative would be to rewrite your application using an active, more current binding like Python or GTK. see https://www.cairographics.org/bindings/
Thank you, that’s what was not clear. Now it’s confirmed that it’s old and best not to use it.
I’ll try to find an alternative and know about the github code now.
Just as an update, I had the code changed to use GTK without needing cairo.
require_once __DIR__ . '/usr/share/php/Composer/vendor/autoload.php';
// Load the GTK library
$gtk = new Gtk();
This is what I’m told;
This script should be compatible with any version of GTK that supports the PHP bindings. The PHP bindings for GTK are provided by the php-gtk package, which is usually available in the package repositories for most Linux distributions.
To install the php-gtk package on Rocky Linux 9, you can run the following command:
# sudo yum install php-gtk
Last metadata expiration check: 0:03:30 ago on Wed 04 Jan 2023 09:50:27 AM MST.
No match for argument: php-gtk
Error: Unable to find a match: php-gtk
# dnf list php-gtk
Last metadata expiration check: 3:13:42 ago on Wed 04 Jan 2023 06:35:15 AM MST.
Error: No matching Packages to list
Of course I also tried php-gtk3 with the same results.
Looking on the net, I find info on compiling old gtk which seems to no longer be supported, replaced by gtk3 but again, cannot find a solution yet.
PHP is mainly used for dynamic web pages (bordering on applicatoins), but ‘cairo’ and ‘gtk’ are related to linux desktop user interfaces, e.g. a window that shows text boxes, buttons and images. PHP does have “Graphics Draw” (GD), which can be used in web pages, e.g. you can create a pie chart as a png file, and then a user can see it in a web browser.
As usual, there’s no clarification about what the user is trying do here.
Why do you say ‘as usual’, that’s rather rude. I didn’t bother to explain it all because it’s not important.
If the packages cannot be installed, it’s why I’m asking, the rest is up to the person that’s writing this code that’s needing all this.
PHP-GTK is from the PHP 5.x days so again, this is also old like cairo. Please see the post above from @ganphxCairo.php. no way to install - #11 by ganphx who found a PHP-CAIRO for PHP 8.x. Providing you install PHP 8.x on your system, then you could follow the instructions there to building the PHP-CAIRO module for you to use.
Yes, I installed php 8. I’ll take a look at the above again. As I said, some of this is over my head and I’m trying to learn/understand but it’s not easy when you’re not a developer.
The code was written to to generate an image but I actually wanted a graph so it’s been changed again.
This time, none of the above is needed and only the PHPGraphLib library