我需要UploadPack
在我的 CakePhp 项目中使用该插件,但是我的蛋糕没有找到该插件的 Helper。我实际上也尝试为自己创建一些自定义助手,但没有一个奏效。我将帮助文件保存在app/src/View/Helper/
(我的自定义帮助程序)和app/plugins/UploadPack/src/View/Helper/
(插件的帮助程序,我没有创建或修改它)中,我已经$helpers[]
在正确的控制器中引用了帮助程序,我不知道还剩下什么做完了。我不知道代码是否相关,但无论如何我都会在下面发布它们。请帮忙。
应用程序/src/Controller/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