Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add the PHPExcel lib top the Docker container and PHP Alpine base image #28

Open
teertz opened this issue Feb 26, 2024 · 2 comments

Comments

@teertz
Copy link

teertz commented Feb 26, 2024

Describe the bug
We are trying to use it in our Docker setup, however, we're encountering the issue:

2.293 checking for libxml2... not found
2.293 checking for xlCreateBookCA in -lxl... configure: error: excel module requires libxl >= 2.4.3

To Reproduce
Steps to reproduce the behavior:
Dockerfile:

FROM php:8.2-alpine AS base

ARG LIBXL_VERSION="4.2.0"

RUN apk add --update linux-headers
RUN apk add --no-cache g++ gcc libxml2 libxml2-dev $PHPIZE_DEPS

#LibXL
RUN cd /tmp \
&& wget http://www.libxl.com/download/libxl-lin-${LIBXL_VERSION}.tar.gz \
&& tar -zxv -f libxl-lin-${LIBXL_VERSION}.tar.gz \
&& cp /tmp/libxl-${LIBXL_VERSION}/lib64/libxl.so /usr/lib/libxl.so \
&& mkdir -p /usr/local/include/libxl_c/ \
&& cp /tmp/libxl-${LIBXL_VERSION}/include_c/* /usr/local/include/libxl_c/

# PHP Excel extension
RUN curl -fsSL 'https://github.com/doPhp/excel/archive/refs/heads/main.zip' -o /tmp/phpexcel.zip \
&& unzip -o /tmp/phpexcel.zip -d /tmp \
&& cd /tmp/excel-main \
&& phpize \
&& ./configure \
--with-excel=shared \
--with-libxl-incdir=/tmp/libxl-${LIBXL_VERSION}/include_c/ \
--with-libxl-libdir=/tmp/libxl-${LIBXL_VERSION}/lib64

Command we use to build it from a docker file is:
docker buildx build --file ./Dockerfile1 ./ --no-cache

@shuguroff
Copy link

Did you find any solutions?

@xperseguers
Copy link

In case this is of some interest, I'm adding this library to my DDEV machine, with a Docker backend, using that .ddev/web-build/Dockerfile.excel and this works just perfectly:

ENV EXTENSION=excel
ENV EXTENSION_REPO=https://github.com/doPhp/excel.git
ENV EXTENSION_VERSION=main
ENV LIBXL_VERSION=4.3.0.14

# LibXL
ADD https://www.libxl.com/download/libxl-lin-${LIBXL_VERSION}.tar.gz /tmp
RUN cd /tmp \
    && tar -xzvf libxl-lin-${LIBXL_VERSION}.tar.gz

# Install the needed development packages
RUN (apt-get update || true) && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests build-essential php${DDEV_PHP_VERSION}-dev
RUN mkdir -p /tmp/php-${EXTENSION} && cd /tmp/php-${EXTENSION} && git clone ${EXTENSION_REPO} .
WORKDIR /tmp/php-${EXTENSION}
RUN git checkout ${EXTENSION_VERSION}
RUN phpize
RUN ./configure \
    --with-excel \
    --with-libxl-incdir=/tmp/libxl-${LIBXL_VERSION}/include_c \
    --with-libxl-libdir=/tmp/libxl-${LIBXL_VERSION}/lib-$(uname -m)
RUN make && make install

RUN echo "extension=${EXTENSION}.so" > /etc/php/${DDEV_PHP_VERSION}/mods-available/${EXTENSION}.ini \
    && chmod 666 /etc/php/${DDEV_PHP_VERSION}/mods-available/${EXTENSION}.ini
RUN phpenmod ${EXTENSION}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants