libvips/php-vips

Undefined C type "VipsConnection" at line 1

allanvb opened this issue · 5 comments

Hello, i'm trying to get php-vips work in my project, but i'm encountering such error when trying to instantiate the Jcupitt\Vips\Image class.

Here are some details about environment. Sorry if something is missing, hope I gave sufficient details.

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

$ uname -r
6.1.8-060108-generic
$ php -v
PHP 8.1.20 (cli) (built: Jun 13 2023 12:02:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.20, Copyright (c) Zend Technologies

$ php -i | grep ffi
/usr/local/etc/php/conf.d/docker-php-ext-ffi.ini,
ffi.enable => On => On
ffi.preload => no value => no value
$ /usr/sbin/apache2 -v
Server version: Apache/2.4.38 (Debian)
Server built:   2023-04-21T22:01:00
$ vips -v
vips-8.7.4-Sat Nov 21 16:50:57 UTC 2020

Dockerfile

FROM php:8.1-apache-buster
...
...
RUN apt-get update && apt-get install -y  \
...
libffi-dev libvips42 libvips libvips-tools

RUN docker-php-ext-install ffi
...
&& a2enmod rewrite headers remoteip expires proxy proxy_fcgi \

php.ini

date.timezone=Europe/Berlin
expose_php=off
post_max_size=120M
upload_max_filesize=120M
user_ini.filename =
display_errors=off
cgi.fix_pathinfo=0
opcache.memory_consumption=256M
memory_limit=2048M
max_execution_time=610
output_buffering=on
ffi.enable=true

jcupitt/vips version - v2.3.0

The use case is simple:

Image::thumbnail($path, $width, ['height' => $height])
// or
Image::newFromFile($path)

Let me know please if you need additional details. Thank you in advance for any advice !

Hi @allanvb,

Your libvips is too old (VipsConnection was added in 8.9, back in 2019). I would update that, if you can.

Having said that, this is also a php-vips bug, since it is supposed to work with libvips 8.7+. I'll see if I can fix it.

Hi @jcupitt ,

Thank you for quick response.

I'll look on my side into why the vips version installed in container is so old. Probably repos (of my Debian) doesn't contain it.

I patched git master php-vips, so if you use that, it ought to work. One test will fail (it's too annoying to fix).

However ... I would still update libvips if you can, recent versions have some useful fixes.

I made you a dockerfile for latest stable libvips on buster:

https://github.com/jcupitt/docker-builds/tree/master/libvips-buster

You'll probably want to adjust the dependencies, depending on what file formats you'd like to support.

@jcupitt on my side I updated the Dockerfile to php:8.1-apache-bookworm,
so now it takes the latest stable for the dist, -v 8.14.1 currently.

Thank you for the dockerfile and quick reaction.

Seems to be good now.
I think this can be closed now.