2014-07-14 54 views
0

我將Zend框架1.12這是我必須把這個腳本每個路由之前採取庫庫時的一個問題:與Zend的路徑問題1.12

require_once Zend_Registry::get('lib_dir').".... 

有辦法使它更容易?,因爲很多文件要修改。問候和感謝提前!

我的結構如下:

>Auth 
    >application 
       >configs 
       >controllers 
       >forms 
       >models 
       >views 
       >Bootstrap.php 
    >docs 
     >library 
       >lib 
        >Google 
          >Auth 
          >Cache 
          >Client.php 
          ...... 

在我的 'UserController的' 我有以下幾點:

 require_once(__DIR__.'/lib/Google/Client.php'); 
    Zend_Loader_Autoloader::getInstance(); 

    $client_id = '1255128545685269859856666.apps.googleusercontent.com'; 
    $client_secret = 'sadFGHDMsdfgh-42552'; 
    $redirect_uri = 'http://localhost/auth/public/user/login'; 

    $client = new Google_Client(); 
    $client->setApplicationName("Procesos"); 
    $client->setClientId($client_id); 
    $client->setClientSecret($client_secret); 
    $client->setRedirectUri($redirect_uri); 
    $client->addScope("https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"); /* Datos Gmail y Google+ */ 

在我 '的bootstrap.php' 我有以下幾點:

<?php 

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap 
{ 
protected function _initAutoload() { 
    $loader = Zend_Loader_Autoloader::getInstance(); 
    $loader->registerNamespace('lib_'); 
} 

} 

Application.ini

includePaths.library = APPLICATION_PATH "/../library" 
autoloaderNamespaces[] = "lib_" 
+0

你能解釋一下你的項目結構嗎?你用你引用的那一行來編輯哪些文件? –

+0

Hello @Thomas,感謝您的快速回復,您可以查看我的更新... – user3680708

回答

0

取決於你在你的項目中,我會建議你依賴遷移庫作曲:

ZF1 with Composer

Google API with Composer

如果你能做到這一點,你不會必須努力添加任何其他庫,因爲它們中的大部分都可用於Composer,並且它們由Composer自動加載器自動加載。

有點骯髒,你仍然可以使用作曲家自動加載谷歌Api,只需添加你的庫作曲家,然後包括你的作曲家自動加載器在你的index.php(或任何你的前端控制器文件被稱爲)。

還有其他的解決方案,但他們都需要包括很多文件。