1 回答

TA貢獻(xiàn)1770條經(jīng)驗 獲得超3個贊
正如 Sudhir 評論過你的那樣,你的應(yīng)用項目中有一個名為 Vendor 的文件夾。我建議你把它放在那里。應(yīng)用程序 > 供應(yīng)商
例如,我創(chuàng)建了一個名為 Csv 的文件夾,用于通過啟動它們的 Shell 生成我自己的 csv 文件。它位于 app > Vendor > Csv 內(nèi)
為了將它導(dǎo)入我的項目,我做了下一個能夠使用它的操作:
<?php
include('GenericShell.php');
require_once(ROOT . DS . 'app' . DS . 'Vendor' . DS . 'Csv' . DS .
'CsvGenerator.php');
class CsvPatientsShell extends GenericShell {
這是 PHP 的唯一示例。
另一種情況是,如果在這種情況下,您有一個名為 component.php 的組件,并且您想將其導(dǎo)入到您在項目中經(jīng)常使用的控制器中:
組件將位于 Controller > Component > Namecomponent.php
接下來你要做的就是在你的控制器中同樣進(jìn)行導(dǎo)入:假設(shè)你的控制器的名稱是 NameController.php 并且位于 Controller 文件夾中??刂破?> NameController.php
public function main_function() {
App::import('Component', 'Namecomponent');
$NameComponent = new NameComponent();
$this->layout = null;
$this->autoLayout = false;
die();
}
這將是使用 CakePhp 的一種更正確的方法,但我會說兩者都是合法的。我希望這會以某種方式幫助你。
- 1 回答
- 0 關(guān)注
- 113 瀏覽
添加回答
舉報