FW: Help with PEAR_Command_Install and PEAR_Command
| From: | Chris Mattmann | Date: | Mon, 07 Apr 2008 00:55:48 +0000 |
| Subject: | FW: Help with PEAR_Command_Install and PEAR_Command | ||
| References: | 1 | Groups: | php.pear.core |
| Request: | Send a blank email to pear-core+get-7450@lists.php.net to get a copy of this message | ||
Hi all,
Okay, last time solving my own problem :)
I figured out the error -- it's because PEAR_Command_Install::doUninstall
expects that the parameters passed to it are _package_names only, not the
full path to the *.tgz file (if using a local URI package in the default
channel like me).
If you add this little snippet to line 1532 in Installer.php, you'll
actually get the real error instead of the confusing one I was getting:
if (PEAR::isError($info)) {
return $this->raiseError($info);
}
Which yielded:
NOT ARRAY ERROR:parsePackageName(): this is not a package name, it begins
with "/" in
"/Users/mattmann/src/211/211linq_installer/211linq_roles/web_role/pear_dists
/PEAR_Installer_Role_Web211linq-1.0.0.tgz
Which was much more helpful than:
PHP Fatal error: Cannot use object of type PEAR_Error as array in
/usr/local/php5/lib/php/PEAR/Installer.php on line 1533
Anyways, just wanted to let everyone know.
Thanks!
Cheers,
Chris
------ Forwarded Message
From: Chris Mattmann <chris.mattmann@gmail.com>
Date: Sun, 06 Apr 2008 17:38:02 -0700
To: <pear-core@lists.php.net>
Conversation: Help with PEAR_Command_Install and PEAR_Command
Subject: RE: Help with PEAR_Command_Install and PEAR_Command
Hi,
So, I actually figured out what the problem was, and wanted pass it along to
everyone.
It turns out the the $ui object is not initialized by default for some
reason when a new PEAR_Command_* class is delivered out of the
PEAR_Command::factory method. You have to explicitly set the $ui object in
order for anything that's printed to $this->ui->outputData to suceed.
So, the fix to my below code would be adding:
$cmd->ui = PEAR_Command::setFrontendClass("PEAR_Frontend_CLI");
Right after $cmd is initialize in my runPEARCommand function.
HTH for anyone out there having a similar problem.
I now have a new problem using the PEAR_Command_Install command's
"uninstall" method. I'm getting an error when trying to uninstall a package
out of the default channel:
PHP Fatal error: Cannot use object of type PEAR_Error as array in
/usr/local/php5/lib/php/PEAR/Installer.php on line 1533
Any ideas?
Cheers,
Chris
------ Forwarded Message
From: Chris Mattmann <chris.mattmann@gmail.com>
Date: Sun, 06 Apr 2008 16:33:39 -0700
To: <pear-core@lists.php.net>
Conversation: Help with PEAR_Command_Install and PEAR_Command
Subject: Help with PEAR_Command_Install and PEAR_Command
Hi there,
I really think that PEAR is awesome, and so far I've been able to figure it
out more or less, even with a very beginner's knowledge of PHP 5 (I used to
program some PHP 4 back in the day but it's literally been about 5 years).
Here is the trouble I have been running into:
I am trying to wrap the "pear install" command, and call it programmatically
through PHP. I have the PEAR Manifesto book, and have read through Chapter
6, where it talks about using PEAR_Command_* to programmatically interface
with the PEAR Installer command line interface. I've managed to write a
small wrapper function that makes a call to a particular PEAR Command:
function runPEARCommand($commandName, $opts, $params, $workDirPath = null) {
if ($workDirPath != null) {
$pwd = getcwd();
chdir($workDirPath);
}
$config = &PEAR_Config :: singleton();
$cmd = PEAR_Command :: factory($commandName, $config);
$ok = $cmd->run($commandName, $opts, $params);
if ($workDirPath != null) {
chdir($pwd);
}
return $ok;
}
This wrapper function has worked great, e.g., for "pear package", e.g.,
using the following code:
echo "INFO: packaging using package.xml file: [" . $pkgFileFullPath . "]\n";
$opts = array ();
$params = array ($pkgFileFullPath);
$commandName = "package";
$ok = $this->runPEARCommand($commandName, $opts, $params, $dirPath);
The problem I am running into is when I try to use my code to wrap "pear
install". The code that I'm using is similar to that of above:
$opts = array ('force'=>true);
$params = array ($filePath); /* $filePath is a path to a .tgz PEAR pkg,
something that I want to install to the default channel */
echo "INFO: Using PEAR to install installer dependency: [" . $filePath .
"]\n";
$ok = $this->runPEARCommand($commandName, $opts, $params);
I'm noticing 2 different behaviors:
1. I've got a pear package that overrides some core PEAR framework code
(e.g., I have one that overrides the default PackageFile/v2/Validator.php
class so that I can have postgres and apache dependency check tags, similar
to pearinstaller). In this case, when I run the above code, I get:
...
INFO: Using PEAR to install installer dependency:
[/Users/mattmann/src/211/211linq_installer/211custom_packagefile/pear_dists/
PEAR_PackageFile_v2_211LinQPackageFile-1.0.0.tgz]
PHP Fatal error: Call to a member function outputData() on a non-object in
/usr/local/php5/lib/php/PEAR/Command/Install.php on line 673
...
2. I've got a traditional pear package that doesn't override core PEAR
framework code, but only adds to it. In this case, when I run the above
code, I get:
...
INFO: Using PEAR to install installer dependency:
[/Users/mattmann/src/211/211linq_installer/211linq_roles/web_role/pear_dists
/PEAR_Installer_Role_Web211linq-1.0.0.tgz]
PHP Fatal error: Call to a member function outputData() on a non-object in
/usr/local/php5/lib/php/PEAR/Command/Install.php on line 750
...
Do anyone have any clue as to why this is happening? I'm also noticing
errors on lines 570: ( PHP Fatal error: Call to a member function
outputData() on a non-object in
/usr/local/php5/lib/php/PEAR/Command/Install.php on line 570), and on lines
1533: ( PHP Fatal error: Cannot use object of type PEAR_Error as array in
/usr/local/php5/lib/php/PEAR/Installer.php on line 1533) if I try to
continue to uninstall using similar code.
I would appreciate any advice you have. Thanks!
Cheers,
Chris
------ End of Forwarded Message
------ End of Forwarded Message