LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   [request] tidy added to the default php extension set? (http://www.linuxquestions.org/questions/slackware-14/%5Brequest%5D-tidy-added-to-the-default-php-extension-set-4175467201/)

piacentini 06-24-2013 01:57 PM

[request] tidy added to the default php extension set?
 
As libtidy is already available in the default packages, would it be a good idea to include the

--with-tidy = shared

option in the default php build? I am not sure about the popularity of the extension, but we used it extensively to validate and clean html entered in input forms.

ljb643 06-24-2013 09:10 PM

Quote:

Originally Posted by Mauricio Piacentini (Post 4977708)
As libtidy is already available in the default packages...

I am pretty sure it isn't. Not in Slackware 14 (or earlier). Is it?

By the way, you probably know you can build a PHP extension (like tidy) without rebuilding all of PHP, right?

XGizzmo 06-24-2013 09:53 PM

tidy gets installed as part of kdewebdev, I am not sure why it is bundled in with kdewebdev. Mauricio, with the way tidy is handled currently I don't think it would be a good idea to make php depend on kdewebdev.

volkerdi 06-24-2013 10:13 PM

PHP seems to bundle the tidy source, so perhaps --with-tidy is all it would take.

I'll look into that.

piacentini 06-25-2013 09:46 AM

Quote:

Originally Posted by ljb643 (Post 4977939)
I am pretty sure it isn't. Not in Slackware 14 (or earlier). Is it?

By the way, you probably know you can build a PHP extension (like tidy) without rebuilding all of PHP, right?

Thanks for your reply. I am using vanilla Slackware 14, tidy was probably pulled in by my full install, which includes KDE and kdewebdev.

BTW, I tried to build only the tidy extension using PECL. But the latest version available there is 1.2, for PHP4. So it fails (understandably) as it can not find some PHP includes.

After some research (http://devzone.zend.com/241/tidying-...ml-with-php-5/) I learned that, beginning in PHP5.03, Tidy is now bundled as an extension in the PHP5 source tree, so the usual method is to configure and build it with PHP, which is what I am doing now. I am actually building it in a separate work tree and just copying the tidy.so, but in order to do this I have to use the same php config settings used by the official build to make sure the extension will still load.

piacentini 06-25-2013 10:05 AM

Quote:

Originally Posted by volkerdi (Post 4977970)
PHP seems to bundle the tidy source, so perhaps --with-tidy is all it would take.

I'll look into that.

Thanks, Patrick. I think it still needs the system libtidy if you configure --with-tidy = shared (I can see a link to libtidy using ldd), but I am not sure if libtidy can be compiled statically into the extension. But as libtidy is already packaged this might not be an issue.

ljb643 06-25-2013 04:54 PM

Tidy itself is not included (bundled) in PHP, neither 5.4.x nor 5.5.x. To build the Tidy extension to PHP, you need the PHP source for the extension (php-<version>/ext/tidy), plus the Tidy source - original source is only available via CVS from sourceforge.net (they do not package up source releases anymore).

You can build the PHP Tidy extension with libtidy compiled as static (libtidy.a, using build/gmake) or shared (libtidy.so).

I did not know about kdewebdev (I don't use it) and that it contains tidy. Thanks for the correction.

You do not need to rebuild PHP to add an extension. There are instructions in README.SELF-CONTAINED-EXTENSIONS within the PHP source distribution. It will be compatible if you follow the steps there. You can just copy the resulting *.so (tidy.so in this case) into the PHP extensions directory, and configure php.ini to load it.

lpallard 06-30-2013 11:04 AM

Quote:

Originally Posted by ljb643 (Post 4978591)
Tidy itself is not included (bundled) in PHP, neither 5.4.x nor 5.5.x. To build the Tidy extension to PHP, you need the PHP source for the extension (php-<version>/ext/tidy), plus the Tidy source - original source is only available via CVS from sourceforge.net (they do not package up source releases anymore).

You can build the PHP Tidy extension with libtidy compiled as static (libtidy.a, using build/gmake) or shared (libtidy.so).

I did not know about kdewebdev (I don't use it) and that it contains tidy. Thanks for the correction.

You do not need to rebuild PHP to add an extension. There are instructions in README.SELF-CONTAINED-EXTENSIONS within the PHP source distribution. It will be compatible if you follow the steps there. You can just copy the resulting *.so (tidy.so in this case) into the PHP extensions directory, and configure php.ini to load it.

If not too much work, would you care to guide me through this process? I just reinstalled Slack64-14 onto my home server and I need the tidy extension... Ive found this thread by searching the web for information!

I think explaining for a begineer like me would be beneficial for everyone.. If not, then I can start a separate thread.

Thanks!

ljb643 06-30-2013 05:37 PM

Quote:

Originally Posted by lpallard (Post 4981210)
If not too much work, would you care to guide me through this process? I just reinstalled Slack64-14 onto my home server and I need the tidy extension... Ive found this thread by searching the web for information!

I think explaining for a begineer like me would be beneficial for everyone.. If not, then I can start a separate thread.

Thanks!

You need the Tidy library (and header files) installed. If you installed it yourself from source, it will be in /usr/local/... and PHP will find it. If you got it from the Slackware KDE package - I'm not sure, you might have to help configure below find it.

You will need the PHP source package, but you only need to extract the PHP Tidy extension, as shown below. Here are my steps to build the PHP Tidy extension. Don't just type these, since your paths etc may differ. "build" is a temporary, empty directory. This also assumes the "phpize" and "phpconfig" commands are on the PATH, as they are with the Slackware package.

Code:

$ cd build
$ tar -xvjf .../php-5.4.16.tar.bz2 php-5.4.16/ext/tidy
$ cd php-5.4.16/ext/tidy
$ phpize
$ ./configure --with-tidy=shared
$ make

The result is modules/tidy.so which you can either use "make install" as root to install, or just copy it to your PHP extensions directory. Change your php.ini to load it. You probably need something like "apachectl restart" to get it to load, and you are done.

Note this works with other PHP extensions too.

piacentini 07-01-2013 12:29 PM

Quote:

Originally Posted by ljb643 (Post 4981362)
You need the Tidy library (and header files) installed. If you installed it yourself from source, it will be in /usr/local/... and PHP will find it. If you got it from the Slackware KDE package - I'm not sure, you might have to help configure below find it.

Just to confirm that the procedure you mention works flawlessly on my machine. So it is a simple way to get the extension, thanks for documenting it.
The procedure requires the php source tarball, as you mention, which is the only drawback imo. And you probably need to remember to repeat it when php is upgraded on the system, which would be easier if the extension was included in the default set. But this is a minor annoyance.

lpallard 07-01-2013 09:30 PM

Quote:

Originally Posted by ljb643 (Post 4981362)
You need the Tidy library (and header files) installed. If you installed it yourself from source, it will be in /usr/local/... and PHP will find it. If you got it from the Slackware KDE package - I'm not sure, you might have to help configure below find it.

You will need the PHP source package, but you only need to extract the PHP Tidy extension, as shown below. Here are my steps to build the PHP Tidy extension. Don't just type these, since your paths etc may differ. "build" is a temporary, empty directory. This also assumes the "phpize" and "phpconfig" commands are on the PATH, as they are with the Slackware package.

Code:

$ cd build
$ tar -xvjf .../php-5.4.16.tar.bz2 php-5.4.16/ext/tidy
$ cd php-5.4.16/ext/tidy
$ phpize
$ ./configure --with-tidy=shared
$ make

The result is modules/tidy.so which you can either use "make install" as root to install, or just copy it to your PHP extensions directory. Change your php.ini to load it. You probably need something like "apachectl restart" to get it to load, and you are done.

Note this works with other PHP extensions too.

Extremely well explained! Worked like a charm ! Many thanks!!!


All times are GMT -5. The time now is 10:06 PM.