2014-01-09 98 views
9

我想實現控制檯工具類(在這裏找到:http://harpanet.com/programming/php/codeigniter/dashboard/index#installation),但它給我錯誤Unable to load the requested class笨第三方類不加載

我曾嘗試在自動加載menually添加該類以及對我的控制器$this->load->library('dash')但這也給了相同的錯誤。

我已選中dash.php並在下面找到方法private function __example__(),但無法理解開發者在評論中所說的內容。

class Dash 
{ 
    private function __example__() 
    { 
     /* 
     * This function is purely to show an example of a dashboard method to place 
     * within your own controller. 
     */ 

     // load third_party hArpanet dashboard library 
     $this->load->add_package_path(APPPATH.'third_party/hArpanet/hDash/'); 
     $dash =& $this->load->library('dash'); 
     $this->load->remove_package_path(APPPATH.'third_party/hArpanet/hDash/'); 

     // configure dashboard widgets - format: type, src, title, cols, alt (for images) 
     $dash->widgets = array(

        array('type'=>'oop',  'src'=>'test_dash',   'title'=>'Test OOP Widget', 'cols'=>3), 

        // if 'title' is set to FALSE, the title block is omitted entirely 
        // note: this is an 'html' widget but is being fed content from a local method 
        array('type'=>'html',  'src'=>self::test_method(), 'title'=>false, 'cols'=>3), 

        array('type'=>'file',  'src'=>'saf_inv.htm',   'title'=>'Safety Investigation'), 

        // multi-content widget - set widget title in outer array (also note use of CI anchor to create a link) 
        array('title'=>anchor('tz', 'TARGET ZERO'), 
          // sub-content follows same array format as single content widget 
          // 'img' content can also have an 'alt' text 
          array('type'=>'img', 'src'=>'saf_tzout.gif',  'alt'=>'Action Completed'), 
          array('type'=>'file', 'src'=>'saf_tz.htm'), 
          array('type'=>'file', 'src'=>'ave_close.htm',  'title'=>'Average Time to Close') 
          ), 

        array('type'=>'file', 'src'=>'saf_meet.htm',  'title'=>'Safety Meeting'), 
        array('type'=>'file', 'src'=>'saf_acc.htm',  'title'=>'Accident Investigation'), 
        array('type'=>'file', 'src'=>'saf_hazmat.htm',  'title'=>anchor('hazmat', 'HAZMAT')), 
        array('type'=>'file', 'src'=>'saf_cont.htm',   'title'=>'Loss of Containment'), 
        array('type'=>'file', 'src'=>'saf_worksinfo.htm', 'title'=>'Works Information'), 

        // an action widget - 'clear' will generate a blank widget with a style of clear:both 
        array('type'=>'clear'), 

        // multi-content widget - width can be set using the 'cols' param in outer array 
        array('title'=>'RAG Report', 'cols' => 2, 

          array('type'=>'file', 'src'=>'saf_rag.htm'), 
          array('type'=>'img', 'src'=>'ProcSaf.gif')), 

        array('type'=>'file', 'src'=>'saf_chrom.htm',  'title'=>'Chrome checks'), 
       ); 

     // populate the view variable 
     $widgets = $dash->build('safety'); 

     // render the dashboard 
     $this->load->view('layout_default', $widgets); 

    } 
................... 

} // end of Dash class 

安裝路徑爲root/application/third_party/hArpanet/hDash/libraries/dash.php

我怎麼能這個類加載到我的系統,並使用小工具?

+0

你是否試過圖書館班級名稱爲'CI_Dash' –

回答

20

你必須創建初始化第三方類庫:

爲如:

--in庫中創建一個名爲mydash.php -

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
class MyDash 
{ 
    public function __construct() 
    { 
     require_once APPPATH.'third_party/hArpanet/hDash/libraries/dash.php'; 
    } 
} 

加載庫使用:

$this->load->library('mydash'); 

那麼你可以使用Dash類。還能夠在自動載入中加載庫。

謝謝...

+2

是的,我做了同樣的事情..謝謝你的支持。 –

3

很遺憾聽到你有問題,(我剛剛注意到這一點SO條目)。感謝ReNiSh的解決方法,非常感謝。

你做不是然而需要使用庫方法來實現hDash的'require_once'。我現在已經寫了一篇演示文稿,介紹如何安裝和運行hDash,您可以在這裏找到:http://harpanet.com/programming/php/codeigniter/dashboard/walkthrough

另外,請注意,截至2014年2月3日,hDash已更新至1.2版。

1

我使用從http://pdfparser.org/

我創建文件的應用程序/庫/ pdf.php

class Pdf 
{ 
    public function __construct() 
    { 
     require_once APPPATH."/third_party/pdfparser.php"; 
    } 
} 

PDF解析器然後,我創建文件的應用程序\ THIRD_PARTY \ pdfparser.php

if (!defined('pdfparser')) { 
    define('pdfparser', dirname(__FILE__) . '/'); 
    require(pdfparser . 'pdfparser/autoload.php'); 
} 

最後,我在目錄中包含PDF解析器庫=> application \ third_party \ pdfparser

+0

這是一個很好的方法! –

+0

Andy能否看看我的問題,關於PDFParser和CodeIgniter?我試圖通過解決問題來解決您的問題...... http://stackoverflow.com/q/41238075/2278301 – John