How to install PEAR with MAMP for OS X?
I'm trying to get PEAR working with MAMP. I'm running the following Auth example from the PEAR website:
<?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 t开发者_运维知识库he 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.
*/
}
?>
And I'm getting this error:
Fatal error: require_once() [function.require]: Failed opening required 'Auth.php' (include_path='.:/Applications/MAMP/bin/php5.3/lib/php')
I have PEAR installed and can even run pear
from the command line, but I am completely stuck trying to get PEAR:Auth to run in this example code. Any help would be greatly appreciated.
You have to include PEAR path in you include_path
in php.ini http://www.php.net/manual/en/ini.core.php#ini.include-path
In that path should be the file Auth.php
, so you can look it up and then getting its parent directory absolute path
精彩评论