php 让 PEAR 在 XAMPP 上工作(Windows 上的 Apache/MySQL 堆栈)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/62658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting PEAR to work on XAMPP (Apache/MySQL stack on Windows)
提问by Donnie Thomas
I'm trying to install Laconica, an open-source Microblogging application on my Windows development server using XAMPP as per the instructions provided.
我正在尝试按照提供的说明使用 XAMPP 在我的 Windows 开发服务器上安装Laconica,这是一个开源微博应用程序。
The website cannot find PEAR, and throws the below errors:
该网站找不到 PEAR,并引发以下错误:
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
警告:require_once(PEAR.php) [function.require-once]:无法打开流:第 31 行的 C:\xampplite\htdocs\laconica\lib\common.php 中没有这样的文件或目录
致命错误:require_once() [function.require]:在 C:\xampplite\htdocs\laconica\lib\common 中打开所需的 'PEAR.php' (include_path='.;\xampplite\php\pear\PEAR') 失败。第 31 行的 php
- PEAR is located in
C:\xampplite\php\pear phpinfo()shows me that the include path is.;\xampplite\php\pear
- 梨位于
C:\xampplite\php\pear phpinfo()告诉我包含路径是.;\xampplite\php\pear
What am I doing wrong? Why isn't the PEAR folder being included?
我究竟做错了什么?为什么不包含 PEAR 文件夹?
回答by user7075
You need to fix your include_pathsystem variable to point to the correct location.
您需要修复include_path系统变量以指向正确的位置。
To fix it edit the php.inifile. 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.
要修复它,请编辑php.ini文件。在该文件中,您会发现一行写着“ include_path = ...”。(您可以通过phpinfo()在页面上运行来找出 php.ini 的位置。)修复了\xampplite\php\pear\PEAR“阅读” C:\xampplite\php\pear“”行的部分。确保将行之前和/或之后的分号留在原位。
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.
重新启动 PHP,您应该就可以开始了。要在 IIS 中重新启动 PHP,您可以重新启动分配给您的站点的应用程序池,或者更好的是,一起重新启动 IIS。
回答by Reid Johnson
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.
如果您使用的是便携式 XAMPP 安装和 Windows 7,并且像我一样在他们从控制面板中删除 XAMPP shell 后拥有该版本,那么这里的任何建议答案都不会对您有多大帮助,因为这些软件包将无法安装。
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
只需在 \xampp\php 目录中拉出一个命令窗口并运行
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.
您需要将“:”替换为您的便携式驱动器当前正在运行的实际驱动器号。不幸的是,这需要在此驱动器号更改时完成,但它确实安装了我需要的模块。
回答by Alex Rapso
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
我首先尝试了所有其他答案,但它们似乎都不起作用,所以我在 pear 配置文件中静态设置了 pear 路径
C:\xampp\php\pear\Config.php
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:
我重新启动了 apache 并使用了命令:
pear config-all
make sure the all of the paths no longer start with C:\php\pear
确保所有路径不再以 C:\php\pear 开头
回答by mpalencia
On Windows use the Xampp shell(there is a 'Shell' button in your XAMPP control panel)
在 Windows 上使用Xampp shell(XAMPP 控制面板中有一个“Shell”按钮)
then
然后
cd php\pear
to go to 'C:\xampp\php\pear'
转到“C:\xampp\php\pear”
then type
然后输入
pear
回答by THEMike
AS per point 1, your PEAR path is c:\xampplite\php\pear\
根据第 1 点,您的 PEAR 路径为 c:\xampplite\php\pear\
However, your path is pointing to \xampplite\php\pear\PEAR
但是,您的路径指向 \xampplite\php\pear\PEAR
Putting the two one above the other you can clearly see one is too long:
把两个放在另一个上面,你可以清楚地看到一个太长了:
c:\xampplite\php\pear\
c:\xampplite\php\梨\
\xampplite\php\pear\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.
您的包含路径设置为在梨树中深入一个 PEAR。pear 文件夹的 PEAR 子文件夹包含 PEAR 组件。您需要将包含路径向上调整一级。
(you don't need the c: by the way, your path is fine as is, just too deep)
(你不需要 c: 顺便说一句,你的路径很好,只是太深了)
回答by Musab ibnu Siraj
I fixed
我解决了
avast deletes your server.php in your directory so disable the antivirus
avast 会删除您目录中的 server.php,因此请禁用防病毒软件
check the (server.php) file on your laravel folder
检查 Laravel 文件夹中的 (server.php) 文件
server.php
服务器.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
$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';
回答by bluestraggler
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.
此类问题的另一个问题是:避免在 Windows 机器上的 Unix shell(例如,Git Bash 或 Cygwin)中运行 pear。我遇到了同样的问题,上面建议的路径修复没有帮助。切换到 Windows shell,pear 命令按预期工作。
回答by Sietse
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:
还要验证 PEAR.php 是否确实存在,它可能在 \php\ 中:
include_path='.;c:\xampplite\php'

