找不到Josegonzalez / Upload.UploadBehavior cakephp 3.x

时间:2016-05-18 13:13:43

标签: cakephp

我在配置Josegonzalez插件时遇到问题,我收到如下错误

Josegonzalez/Upload.UploadBehavior could not be found.

Make sure your plugin Josegonzalez/Upload is in the C:\xampp\htdocs\sunelex\plugins\ directory and was loaded.

错误:在文件中创建下面的类UploadBehavior:C:\ xampp \ htdocs \ sunelex \ plugins \ Josegonzalez / Upload \ src \ Model \ Behavior \ UploadBehavior.php

<?php
namespace Josegonzalez\Upload\Model\Behavior;
use Cake\ORM\Behavior;
class UploadBehavior extends Behavior
{

}

我设法通过composer将插件插入到plugins文件夹中。然后我在boostrap.php中启用插件,如Plugin :: loadAll();我的表类行为代码如下所示。

$this->addBehavior('Josegonzalez/Upload.Upload', [
            'survey_step3_asbestos_pic' => [
                'fields' => [
                    // if these fields or their defaults exist
                    // the values will be set.
                    'dir' => 'photo_dir', // defaults to `dir`
                    'size' => 'photo_size', // defaults to `size`
                    'type' => 'photo_type', // defaults to `type`
                ],
            ],
        ]);

一切都取而代之但是出于某种原因我得到了上面的错误。能否请你帮忙。感谢。

1 个答案:

答案 0 :(得分:-1)

使用下面的cmd install命令。

composer require josegonzalez/cakephp-upload

您需要启用config/bootstrap.php文件的插件:

<?php
Plugin::load('Josegonzalez/Upload');

如果您已经在使用Plugin::loadAll();,则没有必要。