iliaal / php_excel

PHP Extension interface to the Excel writing/reading library
http://ilia.ws
534 stars 131 forks source link

Got an error "Class 'ExcelBook' not found" with php-7.2 and libxl-3.9.1.0 #262

Closed chii1873 closed 4 years ago

chii1873 commented 4 years ago

I installed LibXL library and PHP Extension php7 branch as follows:

cd /usr/local/src
wget https://www.libxl.com/download/libxl-lin-3.9.1.0.tar.gz
tar zxf libxl-lin-3.9.1.0.tar.gz
cd libxl-3.9.1.0
wget https://github.com/iliaal/php_excel/archive/php7.zip
unzip php7.zip
cd php_excel-php7
phpize
./configure --with-libxl-incdir=../include_c --with-libxl-libdir=../lib64
make
make install

vi /etc/php.ini

; 2020-09-29 LibXL PHP Extension
[php_excel]
extension=excel.so

systemctl restart httpd

php -r "print_r(get_loaded_extensions());" | grep excel
    [14] => excel

excel1.php

<?php
ini_set("display_errors", 1);
$excel = new ExcelBook("**", "**", true);
?>

But I got an error: Fatal error: Uncaught Error: Class 'ExcelBook' not found in /path/to/excel1.php:3

I'm using the following modules.

$ rpm -qa | grep php
php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pgsql-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pear-1.10.5-9.module_el8.2.0+313+b04d0a66.noarch
php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
phpPgAdmin-7.12.1-1.rhel8.noarch
php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-devel-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-mbstring-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
wbm-php-pear-1.6-1.noarch
php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pecl-zip-1.15.3-1.module_el8.2.0+313+b04d0a66.x86_64
php-xmlrpc-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-opcache-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-xml-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64

Anyone please tell me what's wrong. Thank you.

chii1873 commented 4 years ago

I reinstalled excel.so and it worked! I forgot to pre-install libxml2-devel and to add --with-libxml-dir parameter when running configure.

dnf install libxml2-devel
cd /usr/local/src/libxl-3.9.1.0/php_excel-php7
phpize
./configure --with-libxl-incdir=../include_c --with-libxl-libdir=../lib64 --with-libxml-dir=/usr/include/libxml
make clean
make
make install
systemctl restart httpd
php -r "print_r(get_loaded_extensions());" | grep excel
    [14] => excel

Thank you anyway.