1

First: I tried 1#

I using Phpspreadsheet and LaravelExcel to make a import.

I creating a new instance of Memcache (not MemcacheD) like the docs in PhpSpreadSheet says (here) and start a new import. In local works fine after I make install all modules for php. But in server (RH7 linux) laravel refuse to indentify the Memcache library.

If I start the Tinker and initialize a new variable using new \Memcache(); laravel found, but in runtime application don't.

Composer packages:

    "require": {
        "php": ">=7.0.0",
        "ext-json": "*",
        "adldap2/adldap2-laravel": "^3.0",
        "barryvdh/laravel-debugbar": "^2.3",
        "cache/memcache-adapter": "^1.0",
        "cache/memcached-adapter": "^1.0",
        "cache/simple-cache-bridge": "^1.0",
        "cocur/slugify": "^3.1",
        "doctrine/dbal": "^2.5",
        "geekcom/validator-docs": "^1.0",
        "laravel/dusk": "^1.0",
        "laravel/framework": ">=5.5",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "^5.3.0",
        "maatwebsite/excel": ">=3.1.13",
        "nwidart/laravel-modules": "^1.19",
        "watson/validating": "^3.0",
        "yajra/laravel-datatables-oracle": "~8.0",
        "zizaco/entrust": "5.2.x-dev"
    },

Some usefully info:

Php Modules installed:

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
intl
json
ldap
libxml
mbstring
memcache
memcached
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

enter image description here

Code:

$client = new \Memcache();
        $client->connect('localhost', 11211);
        $pool = new \Cache\Adapter\Memcache\MemcacheCachePool($client);
        $simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);

        SpreadsheetSettings::setCache($simpleCache);
....

enter image description here

enter image description here

Bruno Luiz K.
  • 168
  • 2
  • 15

1 Answers1

0

PHP uses 2 different php.ini files for php-cli and php-cgi (Fastcgi or Apache mod_php). Sounds like your command line version php.ini has the require extension loading line added i.e extension=memcache.so

But your php-cgi version does not. In any file add phpinfo(); and load it in web browser and locate Loaded Configuration File. Append extension loading line i.e extension=memcache.so to that file and restart the server. Make sure that Memcache is listed in phpinfo(); web page.

tinker
  • 855
  • 1
  • 6
  • 13
  • I founded the php.ini in ```Loaded Configuration File``` and after not found the ```extension=memcache``` I put to end of file, restarted the server and after php --version the message ```PHP Warning: Module 'Memcache' already loaded in Unknow on line 0``` appears* – Bruno Luiz K. Jun 23 '20 at 16:27
  • Hmm.. does the runtime work ? can you post the `phpinfo();` output ? Does it have `Memcache` section ? – tinker Jun 23 '20 at 16:31
  • here: https://pastebin.com/vB8SRqQZ The memcache appears in modules loaded, but the specifications for he do not appears – Bruno Luiz K. Jun 23 '20 at 16:46
  • the section not appears* – Bruno Luiz K. Jun 23 '20 at 16:51
  • Sorry, I couldn't follow you. `but the specifications for he do not appears ` ? what do you mean ? Are you getting the same `Class Memcache not found` error ? – tinker Jun 23 '20 at 16:53
  • Yes, (bad english), the section in phpinfo(); not appears. If I create a new instance of Memcache inside the tinker (in laravel, php artisan tinker) the Memcache works. The memcache only NOT works if executed inside a controller. – Bruno Luiz K. Jun 23 '20 at 16:57
  • 1
    hmm. strange. Can you join this room https://chat.stackoverflow.com/rooms/216517/laravel-5-5-memcache-not-found ? – tinker Jun 23 '20 at 17:09
  • Yes, I are entering the room – Bruno Luiz K. Jun 23 '20 at 17:35
  • I found the solution. The server I are using is a Red Hat centos 7, the maintainer installed a red hat compiled version for php 7.2.24. When I installed the memcache and memcached modules for php he installed in the default directory and installed the version 7.2.28 of php. Then, the version 7.2.24 from Red Hat, was is using in apache 2.0 do not receive the modules. Only the 7.2.28 lts release. I needed to remove the red hat version, remove old httpd folder conf and reinstall from scratch the entire php (with the version 7.2.31), after that the apache get the right version and all works. – Bruno Luiz K. Jun 26 '20 at 12:29