Getting PEAR to work on XAMPP (Apache/MySQL stack on Windows) - php

I'm trying to install Laconica, an open-source Microblogging application on my Windows development server using XAMPP as per the instructions provided.
The website cannot find PEAR, and throws the below errors:
Warning: require_once(PEAR.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampplite\htdocs\laconica\lib\common.php on line 31
Fatal error: require_once() [function.require]: Failed opening required 'PEAR.php' (include_path='.;\xampplite\php\pear\PEAR') in C:\xampplite\htdocs\laconica\lib\common.php on line 31
PEAR is located in C:\xampplite\php\pear
phpinfo() shows me that the include path is .;\xampplite\php\pear
What am I doing wrong? Why isn't the PEAR folder being included?

You need to fix your include_path system variable to point to the correct location.
To fix it edit the php.ini file. In that file you will find a line that says, "include_path = ...". (You can find out what the location of php.ini by running phpinfo() on a page.) Fix the part of the line that says, "\xampplite\php\pear\PEAR" to read "C:\xampplite\php\pear". Make sure to leave the semi-colons before and/or after the line in place.
Restart PHP and you should be good to go. To restart PHP in IIS you can restart the application pool assigned to your site or, better yet, restart IIS all together.

If you are using the portable XAMPP installation and Windows 7, and, like me have the version after they removed the XAMPP shell from the control panel none of the suggested answers here will do you much good as the packages will not install.
The problem is with the config file. I found the correct settings after a lot of trial and error.
Simply pull up a command window in the \xampp\php directory and run
pear config-set doc_dir :\xampp\php\docs\PEAR
pear config-set cfg_dir :\xampp\php\cfg
pear config-set data_dir :\xampp\php\data\PEAR
pear config-set test_dir :\xampp\php\tests
pear config-set www_dir :\xampp\php\www
you will want to replace the ':' with the actual drive letter that your portable drive is running on at the moment. Unfortunately, this needs to be done any time this drive letter changes, but it did get the module I needed installed.

I tried all of the other answers first but none of them seemed to work so I set the pear path statically in the pear config file
C:\xampp\php\pear\Config.php
find this code:
if (!defined('PEAR_INSTALL_DIR') || !PEAR_INSTALL_DIR) {
$PEAR_INSTALL_DIR = PHP_LIBDIR . DIRECTORY_SEPARATOR . 'pear';
}
else {
$PEAR_INSTALL_DIR = PEAR_INSTALL_DIR;
}
and just replace it with this:
$PEAR_INSTALL_DIR = "C:\\xampp\\php\\pear";
I restarted apache and used the command:
pear config-all
make sure the all of the paths no longer start with C:\php\pear

I fixed
avast deletes your server.php in your directory
so disable the antivirus
check the (server.php) file on your laravel folder
server.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';

AS per point 1, your PEAR path is c:\xampplite\php\pear\
However, your path is pointing to \xampplite\php\pear\PEAR
Putting the two one above the other you can clearly see one is too long:
c:\xampplite\php\pear\
\xampplite\php\pear\PEAR
Your include path is set to go one PEAR too deep into the pear tree. The PEAR subfolder of the pear folder includes the PEAR component. You need to adjust your include path up one level.
(you don't need the c: by the way, your path is fine as is, just too deep)

On Windows use the Xampp shell (there is a 'Shell' button in your XAMPP control panel)
then
cd php\pear
to go to 'C:\xampp\php\pear'
then type
pear

Try adding the drive letter:
include_path='.;c:\xampplite\php\pear\PEAR'
also verify that PEAR.php is actually there, it might be in \php\ instead:
include_path='.;c:\xampplite\php'

Another gotcha for this kind of problem: avoid running pear within a Unix shell (e.g., Git Bash or Cygwin) on a Windows machine. I had the same problem and the path fix suggested above didn't help. Switched over to a Windows shell, and the pear command works as expected.

Related

What is php_executable_path in LAMP ubuntu12.04?

I am installing wordpress using Google App Engine and using this command to run the application, app_dir contains app.yaml, php.ini and wordpress:
google_appengine/dev_appserver.py app_dir/
and getting these errors:
File "/home/g1m/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 222, in new_instance
self._check_environment(php_executable_path)
File "/home/g1m/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 147, in _check_environment
'flag (%s) does not exist.' % php_executable_path)
_PHPBinaryError: The path specified with the --php_executable_path flag () does not exist.
I am trying to access the application using this url: localhost:8080 and get following error:
The path specified with the --php_executable_path flag () does not exist.
Kindly help me to solve this, what is the value of php_executable_path in LAMP as I am using UBUNTU12.04 operating system, is it /etc/php/cgi ?
Kindly let me know where I am doing wrong.
Make sure you install it first by doing:
sudo apt-get install php5-cgi
then locate it by running a search for php-cgi
sudo find / -name php-cgi
in my case i found it in : /usr/bin/php-cgi
I think the reason for this error is that GAE need to work with cgi not cli. The difference in them is that cli (command line interface) is for standalone application, not for web app (it didn't output html header by default). If php-cgi is installed , you can specify its path like this when you start dev server
<PATH_TO_SDK>app_devserver.py --php_executable_path=/usr/bin/php-cgi <your_project_name>
If you are not sure, you could search for it like dsb005 suggested.
If it's not installed... hmm... Maybe you miss this one on GAE document :
HP 5.4 is not packaged on most Linux distributions so it may be easiest to install it from source. On Debian-based Linux systems, you can use the following commands to install PHP 5.4 in such a way that it won't effect any other versions of PHP that you may have installed:
I suggest you follow the instruction on
https://developers.google.com/appengine/docs/php/gettingstarted/installinglinux and see if it works. It's always a pay off when you don't read the manual. I did that sometimes :(

PHP: PEAR on windows tries to open c:\windows\pear.ini for writing even though the configuration file is c:\pear\pear.ini

On Windows, when I run
pear config-set auto_discover 1
I get the following error
PEAR_Config::writeConfigFile fopen('C:\Windows\pear.ini','w') failed (fopen(C:\Windows\pear.ini): failed to open stream: Permission denied)
even though I had mentioned during PEAR installation that my config file was c:\pear\pear.ini.
How to fix this, please (without running PEAR in admin mode or changing the permissions of c:\windows\pear.ini)? I guess my problem will be solved if I can figure out where PEAR is getting the directory for pear.ini from.
Thanks!
In the PEAR installation, when I got to the step of modifying the paths I changed the path for pear.ini from C:\Windows\pear.ini to $prefix\pear.ini and I still ran into this same error. Apparently the installation script did not update everything that it needed to.
Based on a comment on a bug report for PEAR (http://pear.php.net/bugs/bug.php?id=16939), I added an environment variable PHP_PEAR_SYSCONF_DIR to point to my PEAR install folder (C:\php\PEAR).
I am now able to successfully run the same config-set command that you were initially attempting to run.
Note the follow-on comment on the bug report however. I only needed one PEAR installation on my machine whereas you may need multiple installations.
I was able to fix this by opening the command prompt as administrator. This is done by right-clicking on the command prompt icon and selecting 'Run as Administrator'. Once command prompt is open, navigate to your php directory and run: php go-pear.phar again. Should run without an issue.
The issue is, when you open your command prompt, your current account doesn't have the privilege to write to your windows directory. Running your command prompt as administrator, will allow for writing to c:\windows
Hope this helps.

how to install DB.php?

I have use DB::Connect in my program for accessing the database.
I ran my php program this shows the error
DB.php file is not their.
require_once 'DB.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);
Then I copy the DB.php file and PEAR.php file from another machine to my
machine after that If I ran from command line it didn't through the error.
while running from browser this shows error. How to solve this problem.?
How to install this DB.php?
PEAR provides a command line installer that should take care of all the details:
pear install DB
Since PEAR packages are mainly PHP code, you can also copy the files manually, but you must make sure you copy everything, not only the first required file, and your script must also be able to find the files so you must add pear to the include_path PHP directive.

PEAR directory problem on Windows

I've downloaded the ZIP archive of PHP and extracted it under my profile. I then needed some PEAR packages. go-pear.bat apparently installed PEAR just fine, I just needed to go into the pear.bat file afterwards and adapt the path to php.exe – no big deal and after that it ran.
However, when I try installing something I get the following error:
ERROR: failed to mkdir C:\php5\pear\data\Console_CommandLine\data
Naturally, no write access is allowed in the root directory but I'm a little at a loss to know how exactly PEAR thinks it should install anything in a location that neither exists nor is configured anywhere. PHP currently resides somewhere below H:\ (subst'ed to my profile). All paths I entered during PEAR installation were sane and the only place I can find C:\php5 is in PEAR/go-pear.phar and in the documentation. One of those is something I shouldn't change anyway, I guess and the other thing is hardly relevant for the program itself.
Now, I probably could go in and make C:\php5 a junction/symlink to the directory where PHP lies currently or actually install it in that location – both things I'd rather avoid since this was originally just intended for a little test of something.
I since looked into pear help install and apparently I can use -P or -R so set some paths. The exact difference between those is still unclear to me but it won't hurt to try them, I guess. Somehow the results were ... unexpected:
-P H:\Downloads\php\PEAR resulted in the fun error (among others)
ERROR: failed to mkdir C:\Downloads\php\PEAR\php5\pear\data\Console_CommandLine\data
while -R using the same path (apparently -R dictates where downloads are stored, since that worked before I guess I shouldn't touch this) resulted in even more fun:
download directory "C:\Downloads\php\PEAR\Users\JOHANN~1\AppData\Local\Temp\pear\download" is not writeable. Change download_dir config variable to a writeable dir
By now I guess both C:\ and php5 are somewhere hardcoded for no apparent reason (my environment variables also contain nothing of that sort) so I'll go digging again, this time looking for shorter string and therefore longer result lists.
But if anyone has an idea about this in the meantime, this might be helpful.
The problem is that PEAR looks for its ini file in the Windows directory, and because it doesn't find it there, it resorts to guessing the location. Even worse, you can't change any configuration settings with pear config-set because PEAR doesn't have a pear.ini to write to. At the same time, PEAR ignores an existing pear.ini file in its own directory. It's a mess. See this bug report.
If there is just one global PEAR install, PEAR can be told where to look for an ini file by creating an environment variable, PHP_PEAR_SYSCONF_DIR, pointing to the right directory.
But if there are multiple, local PEAR installs, you'll have to patch pear.bat by adding this line:
IF "%PHP_PEAR_SYSCONF_DIR%"=="" SET "PHP_PEAR_SYSCONF_DIR=C:\path\to\pear.ini\directory"
A slightly better option than michael h's answer might be:
Open $prefix\pear\PEAR\Config.php where $prefix is the value used in the PEAR installer. (On my Windows system, $prefix was C:\php\5.4.0)
Find the section below:
if (getenv('PHP_PEAR_SYSCONF_DIR')) {
define('PEAR_CONFIG_SYSCONFDIR', getenv('PHP_PEAR_SYSCONF_DIR'));
} elseif (getenv('SystemRoot')) {
define('PEAR_CONFIG_SYSCONFDIR', getenv('SystemRoot'));
} else {
define('PEAR_CONFIG_SYSCONFDIR', PHP_SYSCONFDIR);
}
And make the following changes:
if (getenv('PHP_PEAR_SYSCONF_DIR')) {
define('PEAR_CONFIG_SYSCONFDIR', getenv('PHP_PEAR_SYSCONF_DIR'));
//} elseif (getenv('SystemRoot')) {
//define('PEAR_CONFIG_SYSCONFDIR', getenv('SystemRoot'));
} else {
//define('PEAR_CONFIG_SYSCONFDIR', PHP_SYSCONFDIR);
// This next line is new
define('PEAR_CONFIG_SYSCONFDIR', $PEAR_INSTALL_DIR);
}
This solution is less hazard-prone when dealing with multiple PHP/PEAR versions/installations, especially when running more than one at the same time, as you avoid environment clobbering.
Apparently the PEAR developers overlooked the fact that WINDOWS, Program Files and friends have been deprecated as application-data directories since Windows Vista, and are generally no longer writable by non-elevated applications. (For good security reasons.)
Look at the config-... parameters of the PEAR command:
config-create Create a Default configuration file
config-get Show One Setting
config-help Show Information About Setting
config-set Change Setting
config-show Show All Settings
I presume C:\php5 is the builtin default directory when you don't set another one.
you can specify the config file via
pear -c /path/to/config/file $command
I've had the same problem. My config file was missing from the C:\Windows directory - there is definitely something wrong with the go-pear installer - I specified a different INI file location, yet my wish has not come true.
I copied pear.ini to C:\windows and everything started to work.
If your PHP installation has been done somewhere else other than the C:\ drive, then “pear install” command may throw errors.
Example: Here in my case, the xampp has been installed into E:\ drive and the “pear install” throws error.
Error got when I run the command. This also happen for PHPDocumentor
Solution:
I get into the “pear” directory and checked config values set for different pear related directories. All were set to C:\ drive by default. So, we need to change those settings to correct path.
Open the command prompt in "Run as administrator" mode.
Pear default setting
Now change five path in xampp like this
E:\xampp\php>
E:\xampp\php>pear config-set doc_dir E:\xampp\php\pear
If you are using C drive and getting the same error then also the above statement will remain same just replace the drive name E:\ to C:\ vice versa.
example for C: drive
C:\xampp\php>pear config-set doc_dir C:\xampp\php\pear
Then press enter it will display a msg of config-set succeeded
Like this you have to enter 5 commands.
E:\xampp\php>pear config-set doc_dir E:\xampp\php\pear
config-set succeeded
E:\xampp\php>pear config-set cfg_dir E:\xampp\php\pear
config-set succeeded
E:\xampp\php>pear config-set data_dir E:\xampp\php\pear
config-set succeeded
E:\xampp\php>pear config-set test_dir E:\xampp\php\pear
config-set succeeded
E:\xampp\php>pear config-set www_dir E:\xampp\php\pear
config-set succeeded
Finally installed pear

go-pear.bat file won't install PEAR at all

I just made a new install of WAMP on Windows 7 and I'm trying to get PEAR to work. Things are going wrong from the very beginning. When I try to execute the go-pear.bat file, it shows me this.
phar
"C:\wamp\bin\php\php5.3.1\PEAR\go-pear.phar"
does not have a signature Warning:
require_once(phar://go-pear.phar/index.php):
failed to open stream: pha r error:
invalid url or non-existent phar
"phar://go-pear.phar/index.php" in C:\
wamp\bin\php\php5.3.1\PEAR\go-pear.phar
on line 1236 Press any key to continue
. . .
How can I help it that the file doesn't have a signature?
This blog-post might interest you : Pear: “go-pear.phar” Does Not Have a Signature
It explains how to change a configuration option in php.ini to avoid this error message, and what's said it for WAMP 2.0 and PHP 5.3, so might work in your case.
Just in case anyone comes here from Google: We fixed the .phar download yesterday on http://pear.php.net/go-pear.phar.
In some circumstances (well, actually only on Windows :-)) the file could corrupt from the download. So for example, a lot of people wanted to download it and ended up copy-pasting the contents, etc..
We've asked some people on Windows to test and so far it worked for everyone I talked to. Let me know if it works for you.
Let’s try this from the PEAR directory. cd PEAR and let’s try that again.
php.exe -d phar.require_hash=0 go-pear.phar
Now the PEAR install runs fine.
If the go-pear.bat file won't run, try this procedure:
issue this command with cmd.exe:
php -d phar.require_hash=0 go-pear.phar
Allow the installer to edit php.ini.
Check the contents of PEAR_ENV.reg - located in the PEAR directory YOUR-PHP-INSTALL-PATH\PEAR\ folder (ex. c:\PHP\PEAR\PEAR_ENV.reg) to be sure it has the paths right. Edit as needed and run it. Check your path and environment variables for correctness, then do the same in go-pear.bat and php.ini (mine needed to be corrected to point correctly to my php.exe file).
Issue the
pear
command at the command line to test the path configuration. It will run and do everything but still can't install packages due to a missing dependency.
Download and uncompress Structures_Graph from the PEAR website (direct link).The file has three folders - docs, Structures and tests. Copy the Structure folder into the YOUR-PHP-INSTALL-PATH\PEAR\ folder (ex. c:\PHP\PEAR\Structures).
Issue the command:
pear install Structures_Graph
Even though the files are present, Structures_Graph is not really installed unless you issue the above command.
Issue the command:
pear update PEAR
Enjoy!
Good luck and thanks to Marcos Roriz for the graph dependency half of my solution!

Categories