绑定tidy-html5与PHP?

我想将HTMLTidy( tidy-html5 )的W3C分支设置为PHP扩展。

我已经使用php5-tidy软件包安装了普通的php / tidy扩展。

然后我下载了Git仓库,并运行以下命令来编译共享库:

 sh build/gnuauto/setup.sh && ./configure && make sudo make install 

重新启动php5-fpm服务后,我仍然可以在phpinfo()上看到相同的整理信息:

 libTidy Release 25 March 2009 Extension Version 2.0 ($Id$) 

PHP扩展不应该在这一点上开始使用tidy-html5吗? 我能做些什么来使它工作?

我从PHP中使用Tidy的一个例子:

 $command = "tidy -indent -utf8 -xml -wrap 1000 data/cache/tidy-in.xml > data/cache/tidy-out.xml"; exec($command, $return, $code); if ($code != 0) { throw new Exception(printf("Something went wrong: %s (%s)", join('<br />', $return), $code)); } // the fixed version is here: $html5 = file_get_contents('data/cache/tidy-out.xml'); 

附:

 $command = "tidy -version"; exec($command, $return, $code); if (count($return) > 0) { // command line tidy available } 

你可以testing你是否有一个可用的命令行整洁。 以前Github的HTML5兼容版本在版本文本中有HTML5,现在它只是说'HTML Tidy for Linux版本4.9.18',但我认为这足以处理(例如,如果你想区分HTML5兼容和基本整洁)。

另外一个select:

 if (extension_loaded("tidy")) { // the non-HTML5 php extension... maybe it serves you as fallback.. } 

据我所知tidy-html5不是一个PHP模块,所以你不能直接使用它的PHP。 这只是一个命令行工具和/或共享库。 你可以尝试用新的共享库来构buildPHP

 # configure ... --with-tidy=shared,/usr/local/tidy-html5 

不幸的是,我不是Ubuntu / Debian专家(正如我看到你已经使用过)。 在基于RHEL的系统上,我只需下载并安装http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/SRPMS/php53u-5.3.26-2.ius.el6.src.rpm ,编辑/ root /rpmbuidl/SPESC/php53u.spec和重buildrpm包

 # rpmbuild -ba --target=x86_64 php53u.spec 

据我所知,在debian上你也可以重新编译包。 就像是

 $ sudo apt-get install devscripts build-essential fakeroot $ apt-get source libapache2-mod-php5 php5-tidy $ sudo apt-get build-dep libapache2-mod-php5 $ debuild -us -uc