I'm having trouble installing php-filter extension on a Ubuntu 16.04.7 LTS system.

Currently trying to install it for my php 7.2 cli version.

When I use apt-get install php-filter I get Unable to locate package php-filter response.

I've previously added ppa:ondrej/php repository, from which I've installed many other php extensions, but it seems like it doesn't have this one.

Any ideas how and from where to install this specific extension?


The underlying issue was that the composer version I was using showed me a false message that the php's filter extension wasn't installed, but it was actually a faulty composer version.

By manually removing and installing a fresh composer version I was able to overcome this issue.


Are you sure you don't have it already installed? According to the manual entry it should come with php

The filter extension is enabled by default as of PHP 5.2.0. To disable the filter extension, use --disable-filter.

Maybe you have disabled it at some point.

If not then this GitHub page might help. There you will find these instructions:

php composer.phar require taobig/php-filter

The old Instructions (from 2009) found on waybackmachine call for

pecl install filter
  • php -m shows that this extension is compiled but I'm not sure for which version of php it shows this (I have multiple php versions installed on the system). In /etc/php/7.2/cli/conf.d/ it doesn't show a filter.ini file and from what I've read, this means the extension is not installed. When I try phpenmod filter I get a response Module filter ini file doesn't exist under /etc/php/7.2/mods-available. When I try your suggestion from Github I get a response Could not open input file: composer.phar. Any further suggestions maybe? – Lez Sep 4 '20 at 8:18
  • that error is because you don't have composer you will find instructions on the github page. But please note that this is not the original php-filter but simply someone's project like many others with the same or a similar name and function. There is also the option to try the original intallation method, which I will add to my original anwser. – totalynotanoob Sep 4 '20 at 11:16
  • I appreicate your help and I have upvoted your answer, but I was able to resolve the issue by removing and updating composer. The real issue behind this question was that I had a very old version of composer installed which showed an error that php-filter extension was missing, but it was actually an error in the composer version. Thank you again for your time! – Lez Sep 4 '20 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.