Olaoluwa Faniyi
Olaoluwa Faniyi

Reputation: 21

Class "Memcached" not found on Heroku

I am faced with this problem when I run any artisan commands on Heroku. Its a Lumen-PHP Project. I have added the "ext-memcached" to the require section of the composer.json but still gets the same result.

Screenshot of my terminal

Upvotes: 0

Views: 1698

Answers (1)

Olaoluwa Faniyi
Olaoluwa Faniyi

Reputation: 21

I finally got my hands around this and thanks to the Heroku Docs on Memcached. I quote Heroku Docs:

The php-memcached client is not a pure PHP client but a PECL extention that makes use of libmemcached. You thus need to install php-memcached via your OS package manager.

Make sure you have Memcached Installed on your local machine. You can check a gist I created on how to do this for Mac OSx. I will post it here anyways.

brew install libevent
brew install autoconf
brew install libmemcached

//go to
cd /Applications/MAMP/bin/php/php{{VERSION}}/bin

//compile memcached
./pecl install memcached

//go back
cd ../

//Add the memcached.so extension to your php.ini file
echo -e "\n[memcached]\nextension=memcached.so" >> conf/php.ini

//start memcached server
memcached -m 24 -p 11211 -d

//restart MAMPP

You’ll need to modify your composer.json file to include the module:

{
  "require": {
    "php": ">=7.0.0",
    "ext-memcached": "*"
  }
}

Ensure that your new requirements are “frozen” to composer.lock by running:

composer update

Afterwards, commit your changes and run

git push heroku master

Thats it!!

Upvotes: 2

Related Questions