theseer / phpdox

Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT)
http://phpdox.de
Other
600 stars 121 forks source link

use XSLTProcessor::hasExsltSupport to detect dependency problem around libexsl #379

Open mcfog opened 4 years ago

mcfog commented 4 years ago

run into something like #255 again on my mac today with some error information like

PHP Version: 7.2.18 (Darwin)
PHPDox Version: 0.12.0
ErrorException: E_WARNING
Location: phar:///usr/local/bin/phpdox/vendor/theseer/fxsl/src/fxsltprocessor.php (Line 192)

XSLTProcessor::transformToDoc(): No stylesheet associated to this object

No stacktrace available

I thought I find the problem why it's hard to reproduce by someone, it's related to php build flags. I build my own php binary on my machine (with phpbrew). It seems like phpdox depends on some feature inside EXSLT somehow and a simple --with-xsl build flag leads to a build that support XSL but not EXSLT somehow.

I solved this on my machine by a brew install libxslt and rebuild php with flag --with-xsl=$(brew --prefix libxslt),it can be verified via diff of php -i looks like

834,835c834,837
< libxslt Version => 1.1.29
< libxslt compiled against libxml Version => 2.9.4
---
> libxslt Version => 1.1.33
> libxslt compiled against libxml Version => 2.9.9
> EXSLT => enabled
> libexslt Version => 1.1.33
940,941c942,943

In PHP layer, I found https://www.php.net/manual/en/xsltprocessor.hasexsltsupport.php can also detect this

>>> $proc = new XSLTProcessor;
=> XSLTProcessor {#2304}
>>> $proc->hasExsltSupport()
=> true

So some detailed documentation about the EXSLT dependency and / or runtime detection with XSLTProcessor::hasExsltSupport maybe a good solution to this.

gabrielmuresan commented 4 years ago
     [exec] PHP Version: 7.3.12 (Darwin)
     [exec] PHPDox Version: 0.12.0-dev
     [exec] ErrorException: E_WARNING 
     [exec] Location: /Volumes/OfficeExternalHDD/office/projects/recipe-system-api/vendor/theseer/fxsl/src/fxsltprocessor.php (Line 192)
     [exec] 
     [exec] XSLTProcessor::transformToDoc(): No stylesheet associated to this object
     [exec] 
     [exec] No stacktrace available

I also built the PHP binary using phpbrew and I can confirm the above solution works. Thank you, @mcfog !

theseer commented 4 years ago

Thanks for the heads up! :)