From: "Robert P. J. Day" on

(sort of a solution below):

On Sun, 28 Feb 2010, Robert P. J. Day wrote:

> i'm sure this is easy to fix, but there's a bit of a disconnect
> between the way pyrus works and what the online doc says about it.
>
> running fairly up-to-date fedora 12 system, with PHP 5.3.1:
>
> $ rpm -q php
> php-5.3.1-1.fc12.x86_64
> $
>
> so this system would seem to be pyrus-ready. grab pyrus.phar from
> pear2.php.net, and try:
>
> $ php pyrus.phar
> PHP Fatal error: Class 'XMLReader' not found in
> phar:///home/rpjday/Downloads/pyrus.phar/PEAR2_Pyrus-2.0.0a1/php/pear2/Pyrus/XMLParser.php
> on line 35
> $
>
> the pyrus installation page
> (http://pear.php.net/manual/en/installationpyrus.introduction.php)
> claims:
>
> "Install PHP 5.3.1 or newer. Pyrus needs the phar, simplexml, libxml2,
> spl and pcre extensions in order to work. Fortunately, these are all
> enabled by default in PHP 5.3."
>
> i'm going to suggest that be written a bit more carefully since a
> *lot* of linux versions have pre-packaged version of PHP, and it's not
> clear *how* they're packaged. in any event, you can see what the doc
> page claims above, but if you look inside pyrus.phar, you read:
>
> foreach (array('phar', 'spl', 'pcre', 'simplexml') as $ext) {
> if (!extension_loaded($ext)) {
> echo 'Extension ', $ext, " is required\n";
> exit -1;
> }
> }
>
> note the absence in the code for checking for libxml2, as the doc
> page suggests. but what's the proper way to satisfy that dependency
> these days? and should pyrus.phar explicitly check for that
> extension? i'm trying to clarify this only because the online
> manual strongly suggests that installing pyrus is a piece of cake
> but, depending on your linux distro, you might have a bit of extra
> work to do and that should be documented.

being fairly new to both PHP and PEAR, someone is welcome to correct
me if i misunderstand how extensions work. for pyrus to work, one
*must* have the xmlreader extension/module installed. if that's been
compiled into PHP itself, then great, you're good to go. but on my
fedora 12 system, if i check with phpinfo, it was clearly *not*
configured in:

.... '--disable-xmlreader' '--disable-xmlwriter' ...

now i could build php from scratch but i'd rather not do that -- i
prefer to keep my fedora system maintained via yum-installable
packages, or perhaps using pear or pecl. as i read it, this requires
me to somehow install the xmlreader extension after the fact, correct?
the problem, though, is explained here:
http://www.phpbuilder.com/manual/en/ref.xmlreader.php

"The XMLReader extension is available in PECL for PHP 5.0 and is
included in PHP 5.1 by default. It and can be enabled by adding the
argument --with--xmlreader to your configure line. The libxml
extension is required."

but if you have a prepackaged PHP without that extension, and you
don't want to reconfigure and rebuild, what's your option? i don't
see either an approved pear or pecl extension to install to give me
that. (the PECL xmlreader extension is listed as officially
deprecated and unsupported.)

turns out, after some searching, i chanced across the fedora package
"php-xml", which i yum-installed and which consists of the following
files:

$ rpm -ql php-xml
/etc/php.d/dom.ini
/etc/php.d/wddx.ini
/etc/php.d/xmlreader.ini
/etc/php.d/xmlwriter.ini
/etc/php.d/xsl.ini
/usr/lib64/php/modules/dom.so
/usr/lib64/php/modules/wddx.so
/usr/lib64/php/modules/xmlreader.so
/usr/lib64/php/modules/xmlwriter.so
/usr/lib64/php/modules/xsl.so
$

which is clearly what i was after. but there was nothing to tell me
that, i just *guessed* that there was a fedora package out there and
went looking for it. what are others supposed to do if they need
"xmlreader" capability but don't know where to find it?

rday
--

========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================
From: "Robert P. J. Day" on

regarding installing pyrus on fedora 12 ...

On Sun, 28 Feb 2010, Brett Bieber wrote:

> On Sun, Feb 28, 2010 at 10:11 AM, Robert P. J. Day

[regarding pyrus.phar]

> >> foreach (array('phar', 'spl', 'pcre', 'simplexml') as $ext) {
> >>     if (!extension_loaded($ext)) {
> >>         echo 'Extension ', $ext, " is required\n";
> >>         exit -1;
> >>     }
> >> }

> Pyrus should check for the extension. The file which needs the patch
> is here -
> http://svn.php.net/viewvc/pear2/Pyrus/trunk/stub.php?view=markup

right, i think i had already figured that out -- just adding
'xmlreader' to that list of essential extensions should do it.

> I think the check for the extension could solve a lot of the
> confusion... and perhaps an improved error message: "Pyrus requires
> extension 'X.' You need to compile PHP with 'X' support or install
> an additional package from your o/s provider."

yup, i think that's the simplest solution.

> Within the manual, we may be able to provide some assistance for
> major distros, but I really think this is a fedora issue because
> they are distributing a non-standard binary of PHP. Extensions
> enabled by default should be compiled in or auto-installed.

if there is an *official* list of what extensions should be compiled
into a PHP binary, i can submit a fedora bugzilla request. but i'll
need to be able to point to a legitimate list to back up my request
and defend my position that fedora is currently not doing it right.
got a URL?

> I think we need to patch the manual and the stub.php file, and also
> complain to your distro that PHP extensions which should be enabled
> by default are not installed.

if someone else wants to handle adding that extension test to the
stub.php file, i can put in a fedora bugzilla request, and i can
submit an updated manual page to the docs list that should handle this
for now.

rday
--


========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================
From: "Robert P. J. Day" on

regarding the test in pyrus.phar for essential extensions:

On Mon, 1 Mar 2010, Brett Bieber wrote:

> On Sun, Feb 28, 2010 at 11:31 AM, Robert P. J. Day
> <rpjday(a)crashcourse.ca> wrote:
> >
> >  regarding installing pyrus on fedora 12 ...
> >
> > On Sun, 28 Feb 2010, Brett Bieber wrote:

> >> I think we need to patch the manual and the stub.php file, and
> >> also complain to your distro that PHP extensions which should be
> >> enabled by default are not installed.
> >
> >  if someone else wants to handle adding that extension test to the
> > stub.php file, i can put in a fedora bugzilla request, and i can
> > submit an updated manual page to the docs list that should handle
> > this for now.
>
> I've expanded the extension check and error message. Thanks for your
> help.

a couple more small issues before i move on. first, i notice the
new extension tests (in both stub.php and scripts/pyrus):

foreach (array('phar', 'spl', 'pcre', 'simplexml', 'libxml', 'xmlreader')
as $ext) {
if (!extension_loaded($ext)) {
echo "The $ext extension is required.\n"
. "You must compile PHP with $ext enabled, "
. "or install the necessary extension for your distribution.\n";
exit -1;
}
}

however, the current doc page here:

http://pear.php.net/manual/en/installationpyrus.introduction.php

claims:

"Install PHP 5.3.1 or newer. Pyrus needs the phar, simplexml, libxml2,
spl and pcre extensions in order to work."

do we know the *precise*, minimal set of extensions necessary since
the code now disagrees somewhat with the doc page?

also, i notice in the svn checkout that the final executable
pyrus.phar is part of the repository. isn't that unusual? to have
what is normally *generated* content as part of the repo itself?
especially since that executable is still out-of-date WRT to checking
for the extensions?

wouldn't it make more sense to delete pyrus.phar from the repo, and
simply add to the README file how to build it? or am i missing
something here?

rday
--


========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================