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

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!

Related

How to install PHPUnit with WAMP?

I'm a newbie programmer and I have tried for an embarrassingly long time to get PHPUnit set up and working with WAMP. I have read the documentation and went through various sites to see what I'm doing wrong, but I give up! I need someone to explain this to me in simple terms.
I've probably seen all the guides on how to set it up, but feel free to link me to something you believe is foolproof!
Try this blog : http://nishutayaltech.blogspot.com/2011/04/installing-phpunit-on-windows.html
This setup is for Windows. Hope this will help you.
Also check this out, may be useful http://www.mark-leong.com/installing-php-and-phpunit-on-windows-7/
// adding required pear channels
pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels
// performing install
pear install --alldeps --force phpunit/PHPUnit
If everything ok, check whether phpunit have been installed by putting in command line
phpunit -v
If you encountered any errors or interrupted installing
pear clear-cache
may be usefull in that case.
1) download https://phar.phpunit.de/phpunit.phar
2) run it via php phpunit.phar
Btw if that file ever goes away you can look at the original directions here: https://github.com/sebastianbergmann/phpunit
I recommend using composer. It can be used per project, but also 'globally'.
Make a folder on your C drive called 'globalpackages', then cd into it from the command line.
run 'composer require phpunit/phpunit'
once that finishes run 'composer install'
once that finishes you can check the contents of C:\globalpackages\vendor\phpunit' and should see two phpunit files, one of them a bat.
Add C:\globalpackages\vendor\phpunit to your system path and then you will be able to run phpuni from anywhere on your system.
For me this is the fastests and easiest way.
Make sure you have wamp with WAMP with PHP 7 installed as phpunit requires PHP7 to work! or at least 6.2
Go to folder
wamp64\bin\php\php7.0.10
(wherever you installed your wamp - BEWARE last folder is name of PHP version you have so it might be different then above )
We will be working in this folder during entire installation. So if I say edit file etc it means in this folder.
Download newest version of phpunit from https://phpunit.de/
At the time of writing this I get version phpunit 6.2 and php7.0.10
4. Copy downloaded file to wamp64\bin\php\php7.0.10 folder
For me it's: phpunit-6.2.2.phar
for you it might be different version.
Now change name of the phpunit-6.2.2.phar to phpunit.phar
Now make sure you have added your php to PATH in Environment Variables
To do this on Windows 10 and Windows 8
6a. In Search, search for and then select: System (Control Panel)
6b. Click the Advanced system settings link.
6c. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
6d. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Paste location of your PHP. For me it would be: D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10
(if in PATH there was other command or path just add ";" at the end. For exmaple:
%someOtherCommand%; D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)
6e. Click OK. Close all remaining windows by clicking OK.
In cmd (to run cmd go to search in Windows and type cmd.exe and click Enter)
go to folder wamp64\bin\php\php7.0.10
(to go to folder type for example cd D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)
now once you are in this folder run this command in cmd:
echo #php "%~dp0phpunit.phar" %* > phpunit.cmd
now run this command:
phpunit
you should get list of all commands available in phpunit
now run this:
phpunit --check-version
you will get info what phpunit version you have and if you are using the newest version.
if this doesn't work go to wamp64\bin\php\php7.0.10
Edit file phpunit.bat
Add this line:
""%PHPBIN%" "D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10\phpunit.phar" %*
Repeat point 9.
if it still doesn't work let me know.
Very well done, Emil! You're a star! Perfect answer to install PHPUnit with WAMP on Windows. Look no further than Emil.
https://stackoverflow.com/users/5753967/emil

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.

Wamp 2.2 install PEAR

My operating system is Windows 7.
I got my WAMP2.2 install in my computer.
Then I try to install PEAR.
However, I can not find my go-pear.bat file in my wamp directory.
Fine. I download in here: http://pear.php.net/go-pear.phar
and install using this file.
I put the file in
C:/wamp/bin/php/php5.3.8/pear/go-pear.phar
Run the command: php -d phar.require_hash=0 PEAR/go-pear.phar
After the installation, I include the path of pear in php.ini in php and apache folder.
I also include C:/wamp/bin/php/php5.3.8/ in windows $PATH variable.
But when I run pear command. It said it can not find the pear command.
I check the folder and just find a file called pear.bat and pear.ini.
I tried to run pear.bat again in command line. It still does not work.
Experts, please help on this issue.
Ok since many people may be asking the same thing. Let's suppose the following.
I'm currently running 2.2 E which includes Apache 2.2.22 – Mysql 5.5.24 – PHP 5.3.13 XDebug 2.1.2 XDC 1.5 PhpMyadmin 3.4.10.1 SQLBuddy 1.3.3 webGrind 1.0
Now, to install PEAR do the following:
Download this file:
http://pear.php.net/go-pear.phar
And put it on your WAMP server directory under the PHP version on the bin folder.
Run the command to install PEAR and you're over it.
Example (defaults, no change has been done)
Get the file on the link ->http://pear.php.net/go-pear.phar
Go to this directory C:\wamp\bin\php\php5.3.13
Open command prompt (cmd.exe). Supposing you're using Windows Vista and higher, press Start, type "cmd.exe" and right click on it and select run as administrator/CTRL+SHIFT+Enter (Haven't tested on non-priviliges rights)
Use Window's cd command to change the directory to the go-pear.phar file you've just downloaded. In my case I'll be pin pointing it to my own directory, so I did it like follows:
cd "C:\wamp\bin\php\php5.3.13"
Press Enter. You should note that instead of saying "C:\system\32" is now displaying C:\wamp\bin\php\php5.3.13
Write the following command and press Enter:
php -d phar.require_hash=0 go-pear.phar
Select whether you like or not a local copy or a system one. By typing system:local and pressing enter you'll install a local copy. By typing system and pressing enter you'll install a system-wide copy.
Type yes to confirm the option chosen.
The next list of directories, will be the referring directories that PEAR will install its components. If you select from 1 - 12 you can change the directory you'd like to install. By typing all and pressing Enter you'll be able to change them all in a queued manner. In my case, I just pressed Enter and left all defaults
DO THE FOLLOWING IN CASE YOU CONTINUE TO HAVE SOME LISTINGS
11. It is very probable that afterwards you'll receive a message like:
WARNING! The include+path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified: If the specified directory is also not in the include_path used by your scripts, you will have problems getting any PEAR packages working.
Below it will also appear:
Would you like to alter php.ini ? [Y/n]:
Type y and press enter
This should put you running with PEAR on WAMP server :)
pear.bat is the executable on windows. You have to put that directory in your system's PATH variable for the command to be recognized.
All the steps mentioned to below link for GUI based - easy understanding review and setup:
Click here
For anyone looking for a more current answer. On Windows 10 I had to edit .bash_profile to add the following:
function __pear {
pear.bat $#
}
alias pear=__pear

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

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

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.

Categories