PHP Tidy class not found, error

13,645

Solution 1

Your php.ini contains a list of "extension=somefile.so" lines. You are missing the correct line for your tidy extension. It should be included but commented in your file. Just remove the ; character in front of the one line for the tidy extension and restart your webserver.

Sample for windows:

extension=php_tidy.dll

Sample for Linux:

extension=tidy.so

On some Linux distribution, it has to be installed if you can't find the extension file tidy.so in your extensions folder. Execute the correct line depending on your distribution. You have to be root or use sudo:

CentOS/RedHat (replace with correct lib as found via yum search php-tidy:

yum install rh-php56-php-tidy.x86_64

Debian/Ubuntu:

apt-get install php5-tidy

Solution 2

I had the same issue and I finnally figured it out, this solution is for ubuntu 14.04 running xampp.

step 1
open terminal and input the following

sudo apt-get install php5-tidy

step 2
time to find out where "tidy.so" got installed to.


for me it was installed to "/usr/lib/php5/20121212/tidy.so"

step 3

find and open your php.ini file and find the extensions section and insert the following line

extension=/usr/lib/php5/20121212/tidy.so

step 4

go back to your terminal and run the following to restart your server.

sudo /opt/lampp/lampp restart

step 5

verifying that the new tidy module has been loaded by either

in terminal

php -m

and/or by creating a file on your server in the htdocs called test.php and inserting the following code

<?php echo extension_loaded('tidy') ? "LOADED" : "NOT LOADED"; ?>

next run that test.php file in your browser and it should read "LOADED"

if not go back and review the previous steps until you get that message.

I hope this helps, :)

Share:
13,645
Roberto Rizzi
Author by

Roberto Rizzi

Updated on June 15, 2022

Comments

  • Roberto Rizzi
    Roberto Rizzi almost 2 years

    I was writing some code for repair html string. I read some nice solutions which work with the Tidy PHP class but I had some troubles with it. What in this post is written, is exactly what I want but I need to install / load the PHP Tidy class. Close tags from a truncated HTML string

    I'm working on PHP 5.5.4. I tried to install tidy following some tutorials but nothing has append. When I call the tidy class $tidi = new \tidy();, NetBeans suggests me the class and clicking on it (Ctrl + click) I see it but refreshing the page I obtain the error Class 'tidy' not found in ... /myfile.php line ...

    I used in the same way the class $myVar = new \DomDocument(); but it works perfectly.

    Checking whether the Tidy extension is loaded like below, I get "NOT LOADED".

    echo extension_loaded('tidy') ? "LOADED" : "NOT LOADED";
    

    Please, can someone explain me how Tidy works and how can I set it up? My Ubuntu's version is 13.10.

  • Roberto Rizzi
    Roberto Rizzi over 10 years
    Thank you very much but nothing is working yet. Then, i tried simply adding extension=tidy.so to the /etc/php5/apache2/php.ini and, restarting apache nothing is happened. After that i prompted a locate tidy.so and it gave /usr/lib/libtidy.so. Then i set extension_dir = "/usr/lib" but nothing is still happened. If i launch sudo apt-get install php5-tidy i have an error
  • ToBe
    ToBe over 10 years
    Don't change the extensions folder. What distribution are you using? Did you get any startup errors when just enabling the so?
  • Dylan B
    Dylan B about 7 years
    It should be : yum install rh-php56-php-tidy.x86_64
  • ToBe
    ToBe almost 7 years
    @DylanB Updated.