我正在努力让PEAR与MAMP合作。我正在PEAR网站上运行以下Auth example:
<?php
require_once "Auth.php";
// Takes three arguments: last attempted username, the authorization
// status, and the Auth object.
// We won't use them in this simple demonstration -- but you can use them
// to do neat things.
function loginFunction($username = null, $status = null, &$auth = null)
{
/*
* Change the HTML output so that it fits to your
* application.
*/
echo "<form method=\"post\" action=\"test.php\">";
echo "<input type=\"text\" name=\"username\">";
echo "<input type=\"password\" name=\"password\">";
echo "<input type=\"submit\">";
echo "</form>";
}
$options = array(
'dsn' => "mysql://user:password@localhost/database",
);
$a = new Auth("DB", $options, "loginFunction");
$a->start();
if ($a->checkAuth()) {
/*
* The output of your site goes here.
*/
}
?>
我收到了这个错误:
Fatal error: require_once() [function.require]: Failed opening required 'Auth.php' (include_path='.:/Applications/MAMP/bin/php5.3/lib/php')
我已经安装了PEAR,甚至可以从命令行运行pear
,但我完全不想尝试获取PEAR:Auth在此示例代码中运行。任何帮助将不胜感激。
答案 0 :(得分:1)
您必须在php.ini http://www.php.net/manual/en/ini.core.php#ini.include-path中include_path
中包含PEAR路径
在该路径中应该是文件Auth.php
,因此您可以查找它,然后获取其父目录的绝对路径