我有一个简单的Yii2 REST应用程序。请参见:
如您所见,只有一个模型Category,并且只有一个控制器CategoryController。
Category:
<?php
namespace api\models;
/**
* This is the model class for table "{{%category}}".
*
* @property int $id
* @property string $slug
* @property string $title
* @property int $enabled
*
*/
c
我想创建一个从yii2 Kartik gridview扩展的新类。
namespace mywidget\grid;
use kartik\base\Config;
use kartik\dialog\Dialog;
use kartik\mpdf\Pdf;
use Yii;
use yii\base\InvalidConfigException;
use yii\bootstrap\ButtonDropdown;
use yii\grid\Column;
use kartik\grid\GridView as YiiGridView;
use yii\helpers\ArrayHelper
我正在做作物图像模块,我需要上传图像的细节,所以我使用这个功能。
$image = Image::getImagine()->open($path);
$size = $image->getSize();
在使用这个函数时,它给我带来了错误。
Class 'Imagine\Gd\Imagine' not found
case self::DRIVER_IMAGICK:
if (class_exists('Imagick', false)) {
我想使用DbQueryDependency缓存yii\mongodb\Query,但是我得到了以下内容:
[error][yii\base\InvalidConfigException] yii\base\InvalidConfigException: "yii\caching\DbQueryDependency::$query" should be an instance of "yii\db\QueryInterface". in /vendor/yiisoft/yii2/caching/DbQueryDependency.php:78
Mongodb
我已经在前端文件夹路径为frontend/modules/module-name/Module.php的地方创建了一个模块。我去叫ReflectionException error as Class app\modules\module-name\Module does not exist。在前端/config/main.php中,我添加了以下配置
'modules' => [
'module-name' => [
'class' => 'app\modules\module-name
在activerecord类中,我将以下代码
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
public function behaviors()
{
return [
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => [
我已经创建了一个从yii\base\Component扩展的简单的自定义组件。
namespace app\components\managers;
use yii\base\Component;
use yii\base\InvalidConfigException;
class HubspotDataManager extends Component
{
public $hubspotApiKey;
private $apiFactory;
public function init()
{
if (empty($this->hu
我已经创建了一个新的XmlResponseFormatter,现在我想要更改rootTag。
class newXmlResponseFormatter extends XmlResponseFormatter
{
/**
* @var string the name of the root element.
*
*/
public $rootTag;
public function __construct($rootTag) {
parent::__construct();
$th
我已经通过composer在我的应用程序中安装了简单的聊天小工具。然后我做了它的配置。由于我是yii2新手,无法理解如何在控制台应用程序中进行配置?
我正在遵循上的步骤
当到达**You can access Simple Chat via command line as follows:**的步骤时,如何从上面的链接执行此步骤..??
运行此命令php yii simplechat时出现错误
Exception 'yii\base\InvalidConfigException' with message 'The configuration for
the "
我想动态地创建一个模型的实例。这与yii2是可能的吗?
我正在尝试这样的方法
<?php
namespace app\components;
use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\web\NotFoundHttpException;
use app\models;
class SintelComponent extends Component
{
public function find($model_name, $id)
{
$mag
我试图通过ajax呈现listview,但是它给了我以下错误:
Exception (Invalid Configuration) 'yii\base\InvalidConfigException' with message '
;The "dataProvider" property must be set.
控制器:
public function actionLoadListviewAjax()
{
$dataProvider = // call to a function which re
php init命令的实际作用是什么?
当我在cmd中使用以下命令创建项目后运行此命令:composer create-project --prefer-dist yiisoft/yii2-app-advanced advanced
我看到许多文件在不同的位置生成,比如公共的、后端的、前端的。
`some@user:/var/www/html/yiiapp$ php init
Yii Application Initialization Tool v1.0
Which environment do you want the application to be initialized
这是我第一次使用yii2,我想尝试yii迁移。问题:我创建了迁移文件
php yii migrate/create new_table
文件被创建。然后,我将新的表细节输入到迁移文件中。当我运行php yii migrate时,我得到了错误
Exception 'ReflectionException' with message 'Class db does not exist'
in /var/www/yii2.uz/vendor/yiisoft/yii2/di/Container.php:415,有什么问题?
我的console/config/main.ph
我见过类似的问题,但没有找到可行的解决办法。这是我的index.php文件:
<?php
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../vendor/autoload.p