2011-08-29 68 views
0

我試圖讓梨與MAMP一起工作。我是從PEAR網站運行以下Auth example如何使用MAMP爲OS X安裝PEAR?

<?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:[email protected]/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在此示例代碼中運行。任何幫助將不勝感激。

回答

1

你必須包括在php.ini http://www.php.net/manual/en/ini.core.php#ini.include-path

在這條道路在你include_path PEAR路徑應該是文件Auth.php,所以你可以看看它,然後讓其父目錄的絕對路徑

+1

這是我曾經試過一遍又一遍,沒有任何結果,令我難以置信的沮喪。原來,這是正確的答案,但MAMP不使用php.ini的本地副本,而是在每次重新啓動時從模板文件創建一個新版本。一旦我將PEAR目錄添加到模板的include_path中,事情就開始起作用了。謝謝你的幫助。 –

+0

很高興爲您效勞 –