我需要在CakePhp项目中使用UploadPack
插件,但我的蛋糕找不到插件的助手。我实际上也尝试为自己创建一些自定义助手,但没有一个有效。我有帮助文件保存在app/src/View/Helper/
(我的自定义助手)和app/plugins/UploadPack/src/View/Helper/
(插件的助手,我没有创建也没有修改),我在$helpers[]
中引用了帮助器合适的控制器,我不知道还有什么可做的。我不知道代码是否相关,但无论如何我都会在下面发布。请帮忙。
应用程序/ SRC /控制器/ UsersController.php
<?php
namespace App\Controller;
use App\Controller\AppController;
class UsersController extends AppController {
var $name = 'Users';
var $uses = array('User');
var $helpers = ['Html', 'Form', 'UploadPack.Upload'];
public function add() {
// Do not let logged in users register a new account
if(!isset($this->request->session()->read('Auth')['User']) ||
$this->request->session()->read('Auth')['User']['role']==='admin'){
$user = $this->Users->newEntity($this->request->data);
$user->properties = 'user';
if ($this->request->is('post')) {
if ($this->Users->save($user)) {
$this->Flash->success('The user has been saved.');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error('The user could not be saved. Please, try again.');
}
}
$this->set(compact('user'));
} else {
$this->Flash->error('You are already logged in.');
return $this->redirect(['controller' => 'comments', 'action' => 'index']);
}
}
// Irrelevant code below
}
某些文件架构(包括一些可能不相关的目录)
app/
bin/
config/
plugins/
UploadPack/
src/
Model/
View/
Helper/
UploaderHelper.php
src/
Controller/
UsersController.php
Templates/
Comments/
Users/
add.ctp
edit.ctp
index.ctp
view.ctp
访问localhost:8765/users/
Error: UploadPack.UploadHelper could not be found. Make sure your plugin was
loaded from config/bootstrap.php and Composer is able to autoload its classes,
see Loading a plugin and Plugins - autoloading plugin classes
Error: Create the class UploadHelper below in file:
/home/eburn/comments/plugins/UploadPack/src/View/Helper/UploadHelper.php