Giter Site home page Giter Site logo

yii2-giiant's Introduction

yii2-giiant

"Giiant is huge!"

Build Status

What is this?

Giiant is an extended code-generator for models and CRUDs, based upon Gii (Yii 2.0 Framework).

It creates prototypes for database models and backends including relations defined by foreign-key constrains in no-time.

To provide a highly flexible configuration system it features a callback-provider-queue to define rendering of customized inputs, columns or attribute values.

A main project goal is porting many features and learnings from gtc, giix, awecrud and other code-generators into one solution.

Resources

Features

Batch command

  • yii batch creates all models and/or CRUDs for a set of tables sequentially with a single command

Model generator

  • generates separate model classes to customize and base models classes which can be regenerated on schema changes
  • table prefixes can be stripped off model class names (not bound to db connection settings from Yii 2.0)

CRUD generator

  • input, attribute, column and relation customization with provider queues
  • callback provider to inject any kind of code for inputs, attributes and columns via dependency injection
  • virtual-relation support (non-foreign key relations)
  • model, view and controller locations can be customized to use subfolders
  • horizontal and vertical form layout
  • options for tidying generated code
  • action button class customization (Select "App Class" option on the Action Button Class option on CRUD generator to customize)

Installation

The preferred way to install this extension is through composer.

Using a stable version

composer require schmunk42/yii2-giiant:"@stable"

Using latest master

composer require schmunk42/yii2-giiant:"@dev"

The generators are registered automatically in the application bootstrap process, if Gii module is enabled.

You can try giiant via phd (dockerized PHP application template).

Configuration

It's recommended to configure a customized batch command in your application CLI configuration.

'controllerMap' => [
    'batch' => [
        'class' => 'schmunk42\giiant\commands\BatchController',
        'overwrite' => true,
        'modelNamespace' => 'app\\modules\\crud\\models',
        'crudTidyOutput' => true,
    ]
],

Note: yii giiant-batch is an alias for the default configuration of BatchController registered by this extension.

You can add the giiant specific configuration config/giiant.php, and include this from your config/main.php.

See the batches section for configuration details.

Usage

To create a full-featured database backend, run the CLI batch command

yii batch

You can still override the settings from the configuration, like selecting specific tables

yii batch --tables=a,list,of,tables

Core commands

Show help for gii

yii help gii

Create application-module for giiant CRUDs

yii gii/giiant-module

The commands for generating models and CRUD, there are usually run via the batch command above.

yii gii/giiant-model
yii gii/giiant-crud

Advanced

Provider usage and configuration via dependency injection

See docs for details.

Using callbacks to provide code-snippets

See docs for details.

Troubleshooting

See docs for known-issues, platform specific usage, quirks, faq, ...

Extras

Special thanks to motin, thyseus, uldisn and rcoelho for their work, inspirations and feedback.

Screenshots

giiant-0 2-screen-1 giiant-0 2-screen-2


Built by dmstr

yii2-giiant's People

Contributors

adipriyantobpn avatar battika avatar cebe avatar cgernert avatar christophmuth94 avatar cornernote avatar eluhr avatar fredyns avatar gatis-ozols avatar germanbisurgi avatar gradosevic avatar handcode avatar hector-del-rio avatar ioseogio avatar jwaldock avatar liasica avatar lubobill1990 avatar machtam avatar marc7000 avatar mixartemev avatar mj4444ru avatar motin avatar rhertogh avatar rowasc avatar schmunk42 avatar stphivos avatar thadudexx avatar thiagotalma avatar uldisn avatar zk-kb4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-giiant's Issues

yii2 update recently broke models?

I've been scratching my head for a bit wondering why my show view returned an empty result set (and thus raising an UnknownPropertyException on the $model object.

It appears that this line (Class::find($id)) does not send an sql request (and also does not return null) until the method one is called on it like so:

Class::find($id)->one()

Preview for ModelBase doesn't return correct model

While previewing the generated code it only seems to be able to display the first model. Ift just looks like each model you are going to generate is a copy of whatever the first model is.

  1. I did generate the models and they generated ok it seemed at a glance, in that each model was the correct name and not just one model multiple times. Only thing to note here is that I only wanted to create 1 of the models but all of the available base models I had in my table were created. Looking at the prompts it looks like maybe all the the base models are always generated?

Jonny

RelationProvider dropdown ordering

Hi,
After using giiant a couple of times, I end up using the RelationProvider which is great (at least for one to many relation as of now...)
However, I had a small concern because the values displayed in the dropdown field were sorted by their primary key (id in my case). In most of the case, I guess that people would like it to be sorted by displayed name (name in my case).

I end up modifying the crud/providers/RelationProvider.php file on the line 27 with
\yii\helpers\ArrayHelper::map({$relation->modelClass}::find()->orderBy('{$name}')->all(),'{$pk}','{$name}'),

In my case it makes most of the time more sense to do so, whats your point of view?

Error message on latest update

Thought you'd like to know. I just updated giiant, and where it was working before, now I get this error message:

 PHP Strict Warning – yii\base\ErrorException
Declaration of schmunk42\giiant\model\Generator::generateClassName() should be compatible with yii\gii\generators\model\Generator::generateClassName($tableName, $useSchemaName = NULL)

Add @property namespaces to Base models

When add a new base model all properties phpdoc tags are not related to namespaces classes.

For example

@property Order[] $orders

should be

@property \common\models\Order[] $orders

model generator should create ActiveQuery class

Seems the preferred way to define scopes is via an ActiveQuery class:
yiisoft/yii2#2016

This is what the Gii model generator creates:

<?php

namespace app\models\query;

/**
 * This is the ActiveQuery class for [[\app\models\Job]].
 *
 * @see \app\models\Job
 */
class Job extends \yii\db\ActiveQuery
{
    /*public function active()
    {
        $this->andWhere('[[status]]=1');
        return $this;
    }*/

    /**
     * @inheritdoc
     * @return \app\models\Job[]|array
     */
    public function all($db = null)
    {
        return parent::all($db);
    }

    /**
     * @inheritdoc
     * @return \app\models\Job|array|null
     */
    public function one($db = null)
    {
        return parent::one($db);
    }
}

Should giiant create the same when creating models?

Bad Issue

Scenario:

table = 'app_file',
fields:'id',name_id,'path'

Now i added in the Model File not FileBase

 /**
     * @var the file
     */
    public $file;

    /**
     * file to upload
     * @inheritdoc
     */
    public function rules()
    {
        return array_merge(parent::rules(),[
            ['file', 'file', 'types' => 'jpg,png,gif,mp4,pdf', 'skipOnEmpty' => false],
        ]);
    }

PHP Notice 'yii\base\ErrorException' with message 'Undefined index: file'

because its not in tableShema its only a public var

Fail to generate CRUD from many-to-many relationship

I am having an issue when generating CRUD for a many-to-many relationship. I have two models, Empresa and Regimen, and one table to join them together (for which I have no model since is just a glue table).
When I try to use Giiant CRUD, I get the error:
Unknown Method – yii\base\UnknownMethodException
Calling unknown method: backend\models\Regimen::getEmpresaRegimens()
Which is a method that calls the model EmpresaRegimen that doesn't exist. As far as I am concerned with standards, glue tables like that (only empresa_id and regimen_id being the fields) should not have model file. Or am I wrong in such interpretation?

Anyhow, even if I change the code in the base model from getEmpresaRegimens to the next function,

public function getEmpresas(){
    return $this->hasMany(\common\models\Empresa::className(), ['id' => 'empresa_id'])->viaTable('empresa_regimen', ['regimen_id' => 'id']);
}

the error of the relationship still appears, asking for the same getEmpresaRegimens function. After eliminating the function getEmpresas() the generator works, albeit it doesn't build the relationship. My question is, is my relationship code or the lack of glue model wrong? or is a problem of the generator?
Regards.

Running batch... Error: Unknown command "giic/giiant-model".

On running the batch controller index action getting the following error

Running batch...
Error: Unknown command "giic/giiant-model".

L93: BatchController calling giic/giiant-model action
\Yii::$app->runAction(ltrim($route, '/'), $params);

Not sure If am looking incorrectly, but there does not seems be any such action

Ability to create a base model that is inherited

With Giix, it created a series of base models and also standard models that inherited from the base models. This meant that if there were changes to your DB schema you could just re-run the Giix model generator and it would overwrite the base models with the new schema meaning you didn't run the risk of accidently overwriting your methods in the model. Is this a possibility for Giiant?

Thanks

Jonny

Generating constant holders for attribute names

What do you think about generating constants one for each attribute name for facilitate faster reference in query strings such as

BaseModel.php:
const CUSTOMER_USERNAME='username'
in query where clause later
$model->where([BaseModel::CUSTOMER_USERNAME => 'admin'])

The idea is you don't need to remember the AR attr name but as soon as you type BaseModel:: and you get the constants autosuggested for you. It may accelerate coding this way. You don't have to switch between model files to copy the exact attribute name!

I need help with Providers

i want to use Providers but I can't follow the instruccions from Readme.md. I think this happens to me because i'm new at yii2.

Can you give me some details?

When you say: "Configure providers, add this to your provider list in the form:". What is form?

And when you say "And configure the settings of the provider:"? Which file i have to modify?

Note: i found in yiisoft/yii2/CHANGELOG.md Yii::$objectConfig is removed. You should use Yii::$container->set() to configure default settings of classes. (qiangxue)

Thak you in advance!

CRUD Generation fails when pivot table involved

I really appreciate your extension. It has worked great from me until I came upon a situation involving a pivot table relationship. The specific error that it's throwing is: Calling unknown method: app\models\CrochetPattern::get{crochetPatternTag}s(). It looks like extraneous characters (the braces) are being thrown into the method name and that the name is being inflected when it shouldn't. There is a app\models\CrochetPattern::getCrochetPatternTags() method in the appropriate model. Rather than trying to explain everything here, I'm attaching a jpg with the ERD and a copy of the stack trace leading up to the error. (Actually, I'm mystified why Github won't let me attach a .txt file and forces me to turn the trace into a much larger jpg.)
giiant_crud_error
Hope that helps.

If I'm doing anything wrong, just let me know.
crochet

CRUD error

When you try to log in Giiant CRUD generator:

PHP User Error – yii\base\ErrorException

Exception (Unknown Property) 'yii\base\UnknownPropertyException' with message 'Getting unknown property: schmunk42\giiant\crud\Generator::moduleID'

in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Component.php:143

Stack trace:
#0 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/helpers/BaseHtml.php(1838): yii\base\Component->__get('moduleID')
#1 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/helpers/BaseHtml.php(1139): yii\helpers\BaseHtml::getAttributeValue(Object(schmunk42\giiant\crud\Generator), 'moduleID')
#2 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/helpers/BaseHtml.php(1160): yii\helpers\BaseHtml::activeInput('text', Object(schmunk42\giiant\crud\Generator), 'moduleID', Array)
#3 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/widgets/ActiveField.php(177): yii\helpers\BaseHtml::activeTextInput(Object(schmunk42\giiant\crud\Generator), 'moduleID', Array)
#4 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/widgets/ActiveField.php(149): yii\widgets\ActiveField->render()
#5 /var/www/avtopoch.apronim.io/www/advanced/vendor/schmunk42/yii2-giiant/crud/form.php(12): yii\widgets\ActiveField->__toString()
#6 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php(325): require('/var/www/avtopo...')
#7 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php(247): yii\base\View->renderPhpFile('/var/www/avtopo...', Array)
#8 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2-gii/views/default/view.php(38): yii\base\View->renderFile('/var/www/avtopo...', Array)
#9 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php(325): require('/var/www/avtopo...')
#10 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php(247): yii\base\View->renderPhpFile('/var/www/avtopo...', Array)
#11 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php(149): yii\base\View->renderFile('/var/www/avtopo...', Array, Object(yii\gii\controllers\DefaultController))
#12 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Controller.php(367): yii\base\View->render('view', Array, Object(yii\gii\controllers\DefaultController))
#13 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2-gii/controllers/DefaultController.php(56): yii\base\Controller->render('view', Array)
#14 [internal function]: yii\gii\controllers\DefaultController->actionView('giiant-crud')
#15 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#16 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#17 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('view', Array)
#18 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('gii/default/vie...', Array)
#19 /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#20 /var/www/avtopoch.apronim.io/www/advanced/backend/web/index.php(18): yii\base\Application->run()
#21 {main}

  1. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/ErrorHandler.php at line 233
    224225226227228229230231232233234235236237238239240241242 /**

    • Converts an exception into a PHP error.
      *
    • This method can be used to convert exceptions inside of methods like __toString()
    • to PHP errors because exceptions cannot be thrown inside of them.
    • @param \Exception $exception the exception to convert to a PHP error.
      */
      public static function convertExceptionToError($exception)
      {
      trigger_error(static::convertExceptionToString($exception), E_USER_ERROR);
      }

    /**

    • Converts an exception into a simple string.
    • @param \Exception $exception the exception being converted
    • @return string the string representation of the exception.
      */
      public static function convertExceptionToString($exception)
      {
  2. yii\base\ErrorHandler::handleError(256, 'Exception (Unknown Property) 'yi...', '/var/www/avtopoch.apronim.io/www...', 233, ...)

  3. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/ErrorHandler.php – trigger_error('Exception (Unknown Property) 'yi...', 256) at line 233

  4. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/widgets/ActiveField.php – yii\base\ErrorHandler::convertExceptionToError(yii\base\UnknownPropertyException) at line 151

  5. in /var/www/avtopoch.apronim.io/www/advanced/vendor/schmunk42/yii2-giiant/crud/form.php – yii\widgets\ActiveField::__toString() at line 12
    6789101112131415161718 */

echo $form->field($generator, 'modelClass');
echo $form->field($generator, 'searchModelClass');
echo $form->field($generator, 'controllerClass');
echo $form->field($generator, 'baseControllerClass');
echo $form->field($generator, 'moduleID');
echo $form->field($generator, 'viewPath');
echo $form->field($generator, 'pathPrefix');
echo $form->field($generator, 'indexWidgetType')->dropDownList(
[
'grid' => 'GridView',
'list' => 'ListView',
6. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php – require('/var/www/avtopoch.apronim.io/www...') at line 325
7. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php – yii\base\View::renderPhpFile('/var/www/avtopoch.apronim.io/www...', ['generator' => schmunk42\giiant\crud\Generator, 'form' => yii\widgets\ActiveForm]) at line 247
8. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2-gii/views/default/view.php – yii\base\View::renderFile('/var/www/avtopoch.apronim.io/www...', ['generator' => schmunk42\giiant\crud\Generator, 'form' => yii\widgets\ActiveForm]) at line 38
32333435363738394041424344 ]); ?>



renderFile($generator->formView(), [ 'generator' => $generator, 'form' => $form, ]) ?>
field($generator, 'template')->sticky() ->label('Code Template') ->dropDownList($templates)->hint(' Please select which set of the templates should be used to generated the code. ') ?>

9. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php – require('/var/www/avtopoch.apronim.io/www...') at line 325
10. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php – yii\base\View::renderPhpFile('/var/www/avtopoch.apronim.io/www...', ['generator' => schmunk42\giiant\crud\Generator, 'id' => 'giiant-crud']) at line 247
11. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/View.php – yii\base\View::renderFile('/var/www/avtopoch.apronim.io/www...', ['generator' => schmunk42\giiant\crud\Generator, 'id' => 'giiant-crud'], yii\gii\controllers\DefaultController) at line 149
12. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Controller.php – yii\base\View::render('view', ['generator' => schmunk42\giiant\crud\Generator, 'id' => 'giiant-crud'], yii\gii\controllers\DefaultController) at line 367
13. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2-gii/controllers/DefaultController.php – yii\base\Controller::render('view', ['generator' => schmunk42\giiant\crud\Generator, 'id' => 'giiant-crud']) at line 56
50515253545556575859606162 $params['files'] = $files;
$params['answers'] = isset($_POST['answers']) ? $_POST['answers'] : null;
}
}
}

    return $this->render('view', $params);
}

public function actionPreview($id, $file)
{
    $generator = $this->loadGenerator($id);
    if ($generator->validate()) {
  1. yii\gii\controllers\DefaultController::actionView('giiant-crud')
  2. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/InlineAction.php – call_user_func_array([yii\gii\controllers\DefaultController, 'actionView'], ['giiant-crud']) at line 55
  3. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Controller.php – yii\base\InlineAction::runWithParams(['r' => 'gii/default/view', 'id' => 'giiant-crud']) at line 151
  4. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Module.php – yii\base\Controller::runAction('view', ['r' => 'gii/default/view', 'id' => 'giiant-crud']) at line 455
  5. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/web/Application.php – yii\base\Module::runAction('gii/default/view', ['r' => 'gii/default/view', 'id' => 'giiant-crud']) at line 83
  6. in /var/www/avtopoch.apronim.io/www/advanced/vendor/yiisoft/yii2/base/Application.php – yii\web\Application::handleRequest(yii\web\Request) at line 375
  7. in /var/www/avtopoch.apronim.io/www/advanced/backend/web/index.php – yii\base\Application::run() at line 18
    12131415161718 require(DIR . '/../../common/config/main-local.php'),
    require(DIR . '/../config/main.php'),
    require(DIR . '/../config/main-local.php')
    );

$application = new yii\web\Application($config);
$application->run();
$_GET = [
'r' => 'gii/default/view',
'id' => 'giiant-crud',
];

$SERVER = [
'HTTP_HOST' => 'avtopoch.apronim.io',
'HTTP_CONNECTION' => 'keep-alive',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,
/_;q=0.8',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36',
'HTTP_DNT' => '1',
'HTTP_REFERER' => 'http://avtopoch.apronim.io/advanced/backend/web/index.php?r=gii%2Fdefault%2Fview&id=giiant-model',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, sdch',
'HTTP_ACCEPT_LANGUAGE' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
'HTTP_COOKIE' => 'dle_user_id=1; dle_password=70fce4c199805e5b8e703176bd8c0dd4; dle_compl=0; dle_newpm=0; member_id=1; PHPSESSID=f0d3e78l9853vreu91gtgr8qa7; _csrf=7154364cc64ec598bc12b5f78d4fbf44c12a7148f0029ddbd1694011a47f9b52s%3A32%3A%22dC31l-UicmOOYm-HO5lg7Uocmh6v0CSp%22%3B',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'SERVER_SIGNATURE' => '
Apache/2.2.16 (Debian) Server at avtopoch.apronim.io Port 80

',
'SERVER_SOFTWARE' => 'Apache/2.2.16 (Debian)',
'SERVER_NAME' => 'avtopoch.apronim.io',
'SERVER_ADDR' => '195.211.103.208',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '146.185.187.152',
'DOCUMENT_ROOT' => '/var/www/avtopoch.apronim.io/www',
'SERVER_ADMIN' => 'webmaster@localhost',
'SCRIPT_FILENAME' => '/var/www/avtopoch.apronim.io/www/advanced/backend/web/index.php',
'REMOTE_PORT' => '30744',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'REQUEST_METHOD' => 'GET',
'QUERY_STRING' => 'r=gii%2Fdefault%2Fview&id=giiant-crud',
'REQUEST_URI' => '/advanced/backend/web/index.php?r=gii%2Fdefault%2Fview&id=giiant-crud',
'SCRIPT_NAME' => '/advanced/backend/web/index.php',
'PHP_SELF' => '/advanced/backend/web/index.php',
'REQUEST_TIME_FLOAT' => 1418261101.9960001,
'REQUEST_TIME' => 1418261101,
];

$_COOKIE = [
'dle_user_id' => '1',
'dle_password' => '70fce4c199805e5b8e703176bd8c0dd4',
'dle_compl' => '0',
'dle_newpm' => '0',
'member_id' => '1',
'PHPSESSID' => 'f0d3e78l9853vreu91gtgr8qa7',
'_csrf' => '7154364cc64ec598bc12b5f78d4fbf44c12a7148f0029ddbd1694011a47f9b52s:32:"dC31l-UicmOOYm-HO5lg7Uocmh6v0CSp";',
];
Yii Framework
2014-12-11, 04:25:02

Apache/2.2.16 (Debian)
Yii Framework/2.0.1

Not worl $generator->gridMaxColumns

Exception 'yii\base\UnknownPropertyException' with message 'Getting unknown property: schmunk42\giiant\crud\Generator::gridMaxColumns'

Not work if (++$count < $generator->gridMaxColumns)

Giiant Model Class name always equals only to table name

Hi, I've noticed a strange behaviour with Model Class field when trying to generate Giiant Model. It's required to type something into Model Class field, but it doesn't matter what you type. The name will be equal to table name anyway. I don't know if it was meant to be to behave like this, but I don't think so. Thx!

Giiant CRUD > Unknown Property – yii\base\UnknownPropertyException Getting, unknown property: common\models\User::isAdmin

Hi,

after generating code with Giiant CRUD, I get this error message when trying to reach controller: Unknown Property – yii\base\UnknownPropertyException Getting, unknown property: common\models\User::isAdmin

When I comment this out:
'matchCallback' => function() use ($permission) {
return \Yii::$app->user->can($permission) || (\Yii::$app->user->identity && \Yii::$app->user->identity->isAdmin);
},

it seems to work. What is the problem here? Thx!

Getting unknown property: schmunk42\giiant\crud\Generator::moduleID

PHP User Error – yii\base\ErrorException

Exception (Unknown Property) 'yii\base\UnknownPropertyException' with message 'Getting unknown property: schmunk42\giiant\crud\Generator::moduleID'

in /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/Component.php:143

Stack trace:
#0 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/helpers/BaseHtml.php(1838): yii\base\Component->__get('moduleID')
#1 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/helpers/BaseHtml.php(1139): yii\helpers\BaseHtml::getAttributeValue(Object(schmunk42\giiant\crud\Generator), 'moduleID')
#2 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/helpers/BaseHtml.php(1160): yii\helpers\BaseHtml::activeInput('text', Object(schmunk42\giiant\crud\Generator), 'moduleID', Array)
#3 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/widgets/ActiveField.php(177): yii\helpers\BaseHtml::activeTextInput(Object(schmunk42\giiant\crud\Generator), 'moduleID', Array)
#4 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/widgets/ActiveField.php(149): yii\widgets\ActiveField->render()
#5 /private/var/www/xxx.xxx/vendor/schmunk42/yii2-giiant/crud/form.php(12): yii\widgets\ActiveField->__toString()
#6 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/View.php(325): require('/private/var/ww...')
#7 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/View.php(247): yii\base\View->renderPhpFile('/private/var/ww...', Array)
#8 /private/var/www/xxx.xxx/vendor/yiisoft/yii2-gii/views/default/view.php(38): yii\base\View->renderFile('/private/var/ww...', Array)
#9 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/View.php(325): require('/private/var/ww...')
#10 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/View.php(247): yii\base\View->renderPhpFile('/private/var/ww...', Array)
#11 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/View.php(149): yii\base\View->renderFile('/private/var/ww...', Array, Object(yii\gii\controllers\DefaultController))
#12 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/Controller.php(367): yii\base\View->render('view', Array, Object(yii\gii\controllers\DefaultController))
#13 /private/var/www/xxx.xxx/vendor/yiisoft/yii2-gii/controllers/DefaultController.php(56): yii\base\Controller->render('view', Array)
#14 [internal function]: yii\gii\controllers\DefaultController->actionView('giiant-crud')
#15 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#16 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#17 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('view', Array)
#18 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('gii/default/vie...', Array)
#19 /private/var/www/xxx.xxx/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#20 /private/var/www/xxx.xxx/backend/web/index.php(18): yii\base\Application->run()
#21 {main}

in vendor/schmunk42/yii2-giiant/crud/Generator.php

    public $moduleID;

route user/view in views/index.php not working

Hi,

in views/index.php:

if ($rel = $model->getUser()->one()) {
return yii\helpers\Html::a($rel->id, ["user/view", 'id' => $rel->id,], ["data-pjax" => 0]);

route user/view is not working (yii2-user installed). What else do I have to adjust to make it work? Thanks!

Invalid Parameter – yii\base\InvalidParamException in giiant crud generator

I'm trying to generate a CRUD from a model using the giiant CRUD generator, but when I do so, I get the following error:

'yii\base\InvalidParamException' with message 'Invalid path alias: @backend/views' in C:\php\medexpenses\vendor\yiisoft\yii2\BaseYii.php:152

The stack trace is as follows:
#0 C:\php\medexpenses\vendor\schmunk42\yii2-giiant\crud\Generator.php(175): yii\BaseYii::getAlias('@backend/views') #1 C:\php\medexpenses\vendor\yiisoft\yii2-gii\generators\crud\Generator.php(166): schmunk42\giiant\crud\Generator->getViewPath() #2 C:\php\medexpenses\vendor\yiisoft\yii2-gii\controllers\DefaultController.php(45): yii\gii\generators\crud\Generator->generate() #3 [internal function]: yii\gii\controllers\DefaultController->actionView('giiant-crud') #4 C:\php\medexpenses\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array) #5 C:\php\medexpenses\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array) #6 C:\php\medexpenses\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('view', Array) #7 C:\php\medexpenses\vendor\yiisoft\yii2\web\Application.php(83): yii\base\Module->runAction('gii/default/vie...', Array) #8 C:\php\medexpenses\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request)) #9 C:\php\medexpenses\web\index.php(12): yii\base\Application->run() #10 {main}

I've only just installed giiant this afteroon using Composer, so perhaps I missed a configuration step.

Any ideas?

Docs for Gii Config

In the docs on the home page

$config['modules']['gii'] = array();    
$config['modules']['gii']['class'] = 'yii\gii\Module';
$config['modules']['gii']['generators'] = [
    'giiant-crud' => ['class' => 'schmunk42\giiant\crud\Generator']
    'giiant-model' => ['class' => 'schmunk42\giiant\model\Generator'],
];

Should there be a comma after this line, my editor complained

  'giiant-crud' => ['class' => 'schmunk42\giiant\crud\Generator']

fix Generator.php

line 123 change to

'relations'   => isset($relations[$tableName]) ? $relations[$tableName] : [],

Code Template Option Does not appear

Your instructions only address the installation using the Basic template while I am using the Advanced template. Will this extension work with the Advanced template? I've added the following to frontend/config/main.php:

'modules'    => [
            'gii'      => [
                'class'      => 'yii\gii\Module',
                'generators' => [
                    'giiant-crud'  => ['class' => 'schmunk42\giiant\crud\Generator'],
                    'giiant-model' => ['class' => 'schmunk42\giiant\model\Generator'],
                ]
            ],
                       ...

However, when I go to /gii, the only option that appears within the Code Template dropdown is the native \vendor\yiisoft\yii2-gii template, for both Model and CRUD. I've also tried placing it in common/config/main.php, and the result is the same.

How do I get the option for this set of templates to show up?

Error on dependency injection code in ReadMe.md

Hi,

I finally figured out why I wasn't able to make this promising extension working with my yii2 setup.
It seems that the below code from the readme file is incorrect:

"And configure the settings of the provider, add setting via dependecy injection this to your application config, eg. in console/config/bootstrap.php:"

\Yii::$container->set(
    'schmunk42\giiant\crud\providers\EditorProvider',
    [
        'columnNames' => ['description']
    ]
);

should be

\Yii::$container->set(
    '\schmunk42\giiant\crud\providers\EditorProvider',
    [
        'columnNames' => ['description']
    ]
);

There is one backslash missing at the beginning of the namespace...

Cheers

Model generator doesn't use the Model Class field

Hi again,

I notice that when I'm using the Giiant Model generator, the Model Class field seems not to be used to define the class name and the file name.
In my case, I name the table Countries in my database but would like to get the model generated called Country. I fill the generator form with
Table Name = Counties
Model Name = Country
But the generator keeps creating CountriesBase and Countries files and classes.

I looked into the code and I fix the issue by addiing:
if (isset($this->classNames[$tableName])) {
return $this->classNames[$tableName];
}
at the beginning of the function
protected function generateClassName($tableName)
in the file yii2-giiant/model/Generator.php

Actually I get this piece of code from the yii2-gii generator and I notice that you renamed classNames to classNames2. I didin't dare to touch what you did so I just add my three lines of code.

Any better solution?

table prefix in model generator

after install via composer and setup everything looks fine so far.
need to use table prefix in my db (provider),
just didn't find any config docs in giiant and generating with "tbl_*" gives me
models with "TblTableName" where "TableName" is suggested

Controller generation question

When a controller is generated the create action is handled in a try/catch statement and all caught exceptions are stored as user input error. Is there any specific reason this is handled that way. I am concerned about the security implications this might have!

Thx

tbl_prefix (dynamic)

Hi,

  • Model Class doesn't get tacken for Code Generation -> table with tbl_prefix will always generate class TblTablename
  • function doesn't use the {{%tablename} which would make it more flexible

Thanks Philipp (generating code) :)

Views

if no view path is set no views will be generated . It would be nice to set it as required Field

relation in model correct?

Hi,

I have made a completely new install off yii2, than yii2-user (here I'm not sure if I must migrate or not, and if I have to do this or not: "Make sure that you don't have user component configuration in your config files" - the doc is not 100% clear), than yii2-giiant.
When I generate the first model, with relation to user table, it creates the following relation:
public function getUser()
{
return $this->hasOne(\app\models\User::className(), ['id' => 'UserId']);
}

next, I want to generate Giiant-CRUD, and get the following error:
PHP Fatal Error – yii\base\ErrorException Class 'app\models\User' not found

I think relation should point to some other model (model of yii2-user in vendor\dektrium\yii2-user\models\User.php), or not? Or is there something wrong with yii2-user extension, and that's why it doesn't work? I have no clue.
Thanks!

add Base to parent model

namespace <?= $generator->ns ?>;

use Yii;
use \<?= $generator->ns ?>\base\<?= $className ?> as Base<?= $className ?>;
/**
 * This is the model class for table "<?= $tableName ?>".
 */
class <?= $className ?> extends Base<?= $className . "\n" ?>;
{
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.