GithubHelp home page GithubHelp logo

yiisoft / yii2-gii Goto Github PK

View Code? Open in Web Editor NEW
201.0 38.0 191.0 10.69 MB

Yii 2 Gii Extension

Home Page: http://www.yiiframework.com

License: BSD 3-Clause "New" or "Revised" License

PHP 60.53% JavaScript 3.03% Makefile 0.47% SCSS 35.97%
php yii yii2 code-generator hacktoberfest

yii2-gii's Introduction

Gii Extension for Yii 2


This extension provides a Web-based code generator, called Gii, for Yii framework 2.0 applications. You can use Gii to quickly generate models, forms, modules, CRUD, etc.

For license information check the LICENSE-file.

Documentation is at docs/guide/README.md.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --dev --prefer-dist yiisoft/yii2-gii

or add

"yiisoft/yii2-gii": "~2.1.0"

to the require-dev section of your composer.json file.

Usage

Once the extension is installed, simply modify your application configuration as follows:

return [
    'bootstrap' => ['gii'],
    'modules' => [
        'gii' => [
            'class' => 'yii\gii\Module',
        ],
        // ...
    ],
    // ...
];

You can then access Gii through the following URL:

http://localhost/path/to/index.php?r=gii

or if you have enabled pretty URLs, you may use the following URL:

http://localhost/path/to/index.php/gii

Using the same configuration for your console application, you will also be able to access Gii via command line as follows,

# change path to your application's base path
cd path/to/AppBasePath

# show help information about Gii
yii help gii

# show help information about the model generator in Gii
yii help gii/model

# generate City model from city table
yii gii/model --tableName=city --modelClass=City

yii2-gii's People

Contributors

bwoester avatar cebe avatar creocoder avatar crtlib avatar egorpromo avatar faryshta avatar gevik avatar gonimar avatar kartik-v avatar klimov-paul avatar larryullman avatar lucianobaraglia avatar maksimkiselev avatar mitalcoi avatar mohorev avatar nineinchnick avatar pmoust avatar qiangxue avatar ragazzo avatar resurtm avatar samdark avatar schmunk42 avatar sensorario avatar silverfire avatar slavcodev avatar suralc avatar tarasio avatar thiagotalma avatar tonydspaniard avatar wintersilence 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

yii2-gii's Issues

generate code with gii but keep customization

I made my model generator, because the existing one not keep my changes in model class, if I regenerate the model for example after a table structure changing.

  1. The first idea is, that we make two class instead of one:
    First class:
<?php
namespace app\models\db\core;
/**
 * This is the model class for table "article".
 * @property integer $id
 * @property string $title
 * ......
 */

class CoreArticle extends \yii\db\ActiveRecord {
    /** @inheritdoc */
    public static function tableName()   {
        return 'article';
    }
 // ......
 }

Second class:

<?php
namespace app\models\db;
/** This is the override model class for table "article". */
class Article extends \app\models\db\core\CoreArticle
{ 
}

This second class is empty at the beginning, but here will come the customization, and never will be regenerated.

  1. The second idea is that these model classes from tables we put e.g. to "db" subdirectory, and "core" sub-subdir respectively

'Check This File'-button in modal file-view doesn't update the 'Check All'-checkbox in the file list

Issue

When previewing a file, the 'Check This File'-button at the top of the preview window doesn't update the state of the 'Check All'-checkbox above the file list.

Cause

The function checkFileToggle in gii.js:139 directly changes the checkbox-state instead of triggering a click event. Since no click event is fired, the state of the 'Check All'-checkbox does not get updated.

Proposed solution

Trigger a click event on the checkbox instead of changing its state directly.

gii model generator not working after updating 2.0.3 to 2.0.4

Hi,

We updated composer last night for some other dependancies, and appear to have upgraded gii from 2.0.3 to 2.0.4, and the gii model builder doesn't ... do anything when clicking on preview.

The crud generator appears to work with 2.0.4

When we fixed gii at 2.0.3, and ran another composer update, it downgraded and the model generator works fine with 2.0.3.

cheers

Ben

FWIW

composer.lock @ 2.0.4

      "name": "yiisoft/yii2-gii",
        "version": "2.0.4",
        "source": {
            "type": "git",
            "url": "https://github.com/yiisoft/yii2-gii.git",
            "reference": "e5a023e8779bd774194842ec1b8fb4917cf04007"
        },

and 2.0.3

       "name": "yiisoft/yii2-gii",
        "version": "2.0.3",
        "source": {
            "type": "git",
            "url": "https://github.com/yiisoft/yii2-gii.git",
            "reference": "bb79aeafa8e3b89dd25e07ac895b269680e537a8"
        },

Convert backslashes to forward slashes in view paths

Backslashes in view paths should be automatically converted to forward slash to avoid following common issues:

  • @app\modules/admin/views/user -> will throw exception invalid alias (note backslash \)
  • app/modules/admin/views/user -> will create wrong dirs under @web/app/modules/admin/views/user

It is quite common to copy & paste namespaced paths from previous fields, or enter relative path (without @ alias prefix).

tables with spaces

I am using an MSSQL database, and they use spaces in the tablenames.

The rules on tableName in model/Generator.php prevent this and give the error Only word characters, and optionally an asterisk and/or a dot are allowed..

Model generator, add inverseOf to relations.

I've just implemented this in my model generator. Filling those manually is very error prone (singular vs plural relation names, etc). This be included in core but I've noticed that not all relations need those (excluding many-many). I'd rather remove those unecessary than try to add the required ones.

Should there be an option to generate them, like generateRelations? Maybe generateRelations should be a dropdown with options like:

  • no relations
  • generate relations
  • generate relations with inverse

Add the same view-params to query.php generator as in the model.php

I have to use $tableSchema(yii\db\TableSchema) in the my custom ModelQuery generator, this params(and others) defined right before code below, but view-params is override for query.php

yii\gii\generators\model\Generator::generate()

if ($queryClassName) {
    $params = [
        'className' => $queryClassName,
        'modelClassName' => $modelClassName,
    ];
    $files[] = new CodeFile(
        Yii::getAlias('@' . str_replace('\\', '/', $this->queryNs)) . '/' . $queryClassName . '.php',
        $this->render('query.php', $params)
    );
}

Needs change to:

if ($queryClassName) {
    $params['className'] = $queryClassName;
    $params['modelClassName'] = $modelClassName;

    $files[] = new CodeFile(
        Yii::getAlias('@' . str_replace('\\', '/', $this->queryNs)) . '/' . $queryClassName . '.php',
        $this->render('query.php', $params)
    );
}

gii model generetor suport migrations create

`gii model generetor suport migrations create

In some cases, many in modeling development environment database using something like mysql workbanch then create efetivamamente at your local bank host to generate the model ( and CRUD ) to that entity.

And, generally , stop redistribute the change to other environments ( dev , test , production) it must generate a migration mnualmente generally .

Ideally, the model generator is given Boolean option (Yes or No) to generate the migration file , ie , the migration to create the table in the up ( ) and nothing in the down ( )

Using Gii Console always complains for blank properties

I try to generate Code from Gii command line. So I tried to create controller and got error that controller and its base are blak. as you see in this command they are not empty. Here is the command

yii gii/controller --baseClass=yii\web\Controller --controllerClass=app\common\controllers\PostController --actions=index,view,edit,delete 

and the result I get is

Running 'Controller Generator'...

Code not generated. Please fix the following errors:

 - controllerClass: Controller Class cannot be blank.
 - baseClass: Base Class cannot be blank.

Then I tried to generate module and ran:

php  yii  gii/module --moduleClass=TestModule --moduleID=test 

and got

Running 'Module Generator'...

Code not generated. Please fix the following errors:

 - moduleID: Module ID cannot be blank.
 - moduleClass: Module Class cannot be blank.

As far as I can say this is a bug. Tried to go thru the codes and got lost in there so I could not check it (I have no PHP debugger right now)

TIA,
S.

Generate a base file for models

Hello everybody,

Now that the Gii has its own home, I would like to take a subject that has been discussed here but the topic died.

The idea of having an ever synchronized file with the database is very interesting. Some mods of gii (the old Giix from @rcoelho and Giiant, from @schmunk42, for example) implement this idea. Ever since I started working in Yii have my gii modified to generate this base file.

It makes it much easier to keep the model always synchronized with the database. In the data model file override only those methods that are needed, usually adding rules or correcting labels.

The only "problem" I see this to be officially implemented is the question of performance, as it will add an inheritance.

I ask the experts: the loss of performance is really relevant?

Having this functionality as an option in Gii would be helpful?

Hugs!

Problems with typeahead.js / new release

I just created this issue about typeahead.js (#38, #39)

Btw, we're experiencing some issues with the latest updates in gii...

reading changelogs

Did someone notice this?

https://github.com/twitter/typeahead.js/blob/master/CHANGELOG.md

0.11.0 April 25, 2015

An overhaul of typeahead.js โ€“ consider this a release candidate for v1. There are bunch of API changes with this release so don't expect backwards compatibility with previous versions. There are also many new undocumented features that have been introduced. Documentation for those features will be added before v1 ships.

Beware that since this release is pretty much a rewrite, there are bound to be some bugs. To be safe, you should consider this release beta software and throughly test your integration of it before using it in production environments. This caveat only applies to this release as subsequent releases will address any issues that come up.

This would explain several issues we have, but I'll need to investigate this further.

@qiangxue @samdark @cebe @klimov-paul
If this is not an issue, it would be nice to have a patch release 2.0.5.

If the typeahead.js changes are affecting gii, I've the feeling that this could lead into some weird to find problems, and would therefore strongly recommend 2.1.0(!).

HTML5 input support for form generator

See yii2 issue #9348

We should update model form generation for support HTML5-types.

For example, for this rule

[['fieldxyz'], 'integer', 'min' => 10, 'max' => 20]

should be generated such as this field

<?= $form->field($model, 'fieldxyz')->input('number', ['min' => 10, 'max' => 20]) ?>

Creating CRUD into a module, Gii will preview 2 files as they will be outside the module

[Please, fix the title, my english is so bad]

I'm using the advanced template as base for my app.
I've succesfully generated (using gii) the module 'admin'
I'm using the Gii CRUD generator from v 2.0.4 to create the full crud for User class (part of the advanced template, unmodified until now).

These are entered params:

  • Model Class: common\models\User
  • Search Model Class: frontend\modules\admin\models\UserSearch
  • Controller Class: frontend\modules\admin\controllers\UserController
  • View Path: frontend\modules\admin\views\user

Look at list of generated file: the first two are outside the module.

modules\admin\controllers\UserController.php
modules\admin\models\UserSearch.php
frontend\modules\admin\views\user\_form.php
frontend\modules\admin\views\user\_search.php
frontend\modules\admin\views\user\create.php
frontend\modules\admin\views\user\index.php
frontend\modules\admin\views\user\update.php
frontend\modules\admin\views\user\view.php

This is only a visual bug because Gii will create all the files in the right folder:

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   frontend/modules/admin/controllers/UserController.php
        new file:   frontend/modules/admin/models/UserSearch.php
        new file:   frontend/modules/admin/views/user/_form.php
        new file:   frontend/modules/admin/views/user/_search.php
        new file:   frontend/modules/admin/views/user/create.php
        new file:   frontend/modules/admin/views/user/index.php
        new file:   frontend/modules/admin/views/user/update.php
        new file:   frontend/modules/admin/views/user/view.php

'Check This File'-button in modal file-view doens't change the corresponding checkbox

Issue

When previewing a file, the 'Check This File'-button at the top of the preview window doesn't change the checkbox corresponding to the file being previewed.
Instead, it always changes the checkbox corresponding to the last file in the list.

Cause

The function fillModal in gii.js:66 uses $(this) as if it points to the anchor-element corresponding to the file being previewed. In practice, though, it actually points to the Window-element.

Proposed solution

Provide fillModal with the correct object through an extra argument.

Trying to get property of non-object [in ...vendor\yiisoft\yii2-gii\generators\model\Generator.php at line 511]

Hi all, i'm getting this error when i try to generate new Model.
I see that if i uncheck " Generate Relations" (default checked) it works, but i need to create manually relation of my table /foreign keys

I try to delete yii2-gii directory and re-launch composer but i have the same issue.

There are many weeks that i don't use gii because i deploy different section my project, but i'm sure that when i used it at the beginning of my project "Generate Relations" works fine.

Gii generator overrides files, even when instructed not to override

See title.

Example:
./yii gii/model --generateQuery --tableName=*

Output (excerpt):

The following files will be generated:
  [...]
  [unchanged] models/Bet.php
    [changed] models/Match.php
Do you want to overwrite this file? [y,n,ya,na,?]: n
  [unchanged] models/Matchday.php
        [new] models/Score.php
    [changed] models/Team.php
Do you want to overwrite this file? [y,n,ya,na,?]: n
    [changed] models/User.php
Do you want to overwrite this file? [y,n,ya,na,?]: n

Ready to generate the selected files? (yes|no) [yes]:y

Files were generated successfully!
Generating code using template "/home/vsx/public_html/clibot/vendor/coksnuss/yii2-gii-modelgen/generators/model/default"...
   [...]
   skipped models/Bet.php
 overwrote models/Match.php
   skipped models/Matchday.php
 generated models/Score.php
 overwrote models/Team.php
 overwrote models/User.php
done!

The generator overwrote the files Match.php, Team.php and User.php against the given instructions!

I have not look into the issue yet, but I think the error is in https://github.com/yiisoft/yii2-gii/blob/master/Generator.php#L273, where the comparision of $answers[$file->id] is missing. Basically the isset() call should be removed.

Gii Generate only Search Model feature

Hi,
Right now I use CRUD to create everything, but in fact I need only search model,
so after generate done, I remove every thing except search model.

It's will be better if you provide new feature to generate only search model.

Best Regards,
Yo.

GII CRUD: flash messages after actions

Hi mans!

It reported in yiisoft/yii2#3428 (comment)

say...

@lucianobaraglia commented on 11 May 2014
I think it would be nice having flash messages in crud after common actions were performed.
For example, after deleting something, I would expect to read: "The item was successfully deleted", and after creating or updating: "The item was created/updated successfully".

Or something like that.

I will code this change , some opposition ?

Problem with table schemas in Yii 2.0.6

I could not find any possible solution, because I just don't know how Gii really works. The error only occurs if Generate Relations is checked and looks like this:

image

The settings are:

image

The DB is a SQL Server 2014.

Check out the links to resources

Please check out the links in composer.json on resources
Perhaps after moving some change

{
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Agii",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
}

Error: yii\db\mysql\Schema does not support fetching all schema names.

ver: 2.0.6-dev
Error: yii\db\mysql\Schema does not support fetching all schema names.

why this code here?

        if ($schema->hasMethod('getSchemaNames')) { // keep BC to Yii versions < 2.0.4
            try {
                $schemaNames = $schema->getSchemaNames();
            } catch (NotSupportedException $e) {
                // schema names are not supported by schema
            }
        }

in the generators\model\Generator.php
https://github.com/yiisoft/yii2-gii/blob/master/generators/model/Generator.php#L387

sorry for bad english

Related table "description" in gridview generation

Following the DRY and convention over configuration principles would it be possible to add this functionality to the GII generated gridview (at least!)?

In view file:

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'driver_status_id',
            [ 
                'attribute'=>'driver_status_id', 
--->            'format'=>'text',//raw, html 
--->            'content'=>function($data){return $data->getDriverStatusRepresentation();} 
            ], 
            'own',
            'supplier_id',
            'last_names',
            'first_names',
            'document_number',
            'birth_date:date',
            'driving_license_expiration:date',
            ['class' => 'yii\grid\ActionColumn',],
        ],
    ]); ?>

In model file:

    public function getDriverStatus()
    {
        return $this->hasOne(QryDriverStatus::className(), ['id' => 'driver_status_id']);
    }

--->    public function getDriverStatusRepresentation()
--->    { 
--->        $model=$this->driverStatus; 
--->        return $model?$model->driver_status:''; 
--->    } 

Since I understand that "no rule" can be imposed in the naming of the description associated to the primary key (id) of the related table, I would suggest that by default this will get back the primary key allowing this way to only modify the field used to "represent" the related table.

Exist rules for foreign keys - namespace

I'm not sure if I've missed something (due to customisation) but the new exist rules are causing errors due to the $refClassName not being fully qualified. Is this expected behaviour, because I can code a workaround in my custom code, but thought I'd point it out in case of errors for other users.

Relations on Model [enhancement]

I have an idea to add relations function like on Yii 1.1

The function is like this

public function relations() {
    return [
        // 'relationName' => [isHasMany, FullyQualifiedRelationModelClassName, RelationModelClassName, [Link]]
            'modelDetails' => [1, $this->getRelation('modelDetails')->modelClass, 'ModelDetail', ['ModelDetailForeignKey' => 'ModelPrimaryKey']]
        ];
    }
}

The Generator class need to add $link on function generateRelations()

...
$relations[$className][$relationName] = [
    "return \$this->hasOne($refClassName::className(), $link);",
         $refClassName,
         false,
         $link
];
...

$relationName = $this->generateRelationName($relations, $refClassName, $refTable, $className, $hasMany);
$relations[$refClassName][$relationName] = [
    "return \$this->" . ($hasMany ? 'hasMany' : 'hasOne') . "($className::className(), $link);",
        $className,
        $hasMany,
        $link
];
...

Then, on model.php template, add

<?php if (!empty($relations)): ?>

    /**
     * @return array relations for model. [ relationName => [ isHasMany, relation class, fully qualified relation class, link ]
     */
    public function relations()
    {
        return [
<?php foreach ($relations as $name => $relation): ?>
            '<?= lcfirst($name) ?>' => [<?= $relation[2] ?>, '<?= $relation[1] ?>', $this->getRelation('<?= lcfirst($name) ?>')->modelClass, <?= $relation[3] ?>],
<?php    endforeach; ?>
        ];
    }
<?php endif; ?>

The purpose of this function is for creating functions like loadWithRelation() for example

public function loadWithRelation($POST) {
    if ($this->load($POST)) {
        foreach ($this->relations() as $name => $relation) {
            if (isset($POST[$relation[1]])) {
                $container = [];
                $relationPKAttr = $relation[2]::getTableSchema()->primaryKey[0];
                foreach ($POST[$relation[1]] as $rModel) {
                    $tmp = (!empty($rModel[$relationPKAttr])) ? $relation[2]::findOne($rModel[$relationPKAttr]) : new $relation[2];
                    $tmp->load([$relation[1] => $rModel]);
                    $container[] = $tmp;
                }
                $this->populateRelation($name, $container);
            }
        }
        return true;
    }
    return false;
}

All the code above is tested & working.

If the function relations() is available on the Model, then I have the idea of

  1. Gii can generate the relation CRUD (form, detail view)
  2. Function saveWithRelation() and loadWithRelation() (like the above) on ActiveRecord

What do you guys think? Should i create a pull request?

Full date/time support in GII generated CRUD

Is there a chance to have GII automatically generate the ":date" or ":time" or ":datetime" just to close the good Datetime support in GII2?
Example:

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            //'id',
            'driver_status_id',
            'own',
            'supplier_id',
            'last_names',
            'first_names',
            'document_number',
--->            'birth_date:date',
            'driving_license_expiration:date',
            ['class' => 'yii\grid\ActionColumn',],
        ],
    ]); ?>

crud generation creates bad urls

It seems like the crud generator is creating the urls for the forms buttons incorrectly for me. Instead of getting the correct create url:

http://my.domain.com/model/create

i get the following:

http://my.domain.com/modelcreate

This happens for all buttons from the generated forms.

Just some information, i am working on localhost and have pretty urls activated.

Edit: it seems i have a problem in general with the way urls are being generated on my application in general. Ex:

Html::a('index', ['site/index']);

Gives me the following output

http://my.domain.com/siteindex

Using viaTable() or via() method

Why gii Model generator, by default, creates links between different models using the method viaTable() and not via()

public function getPageTags()
{
    return $this->hasMany(PageTags::className(), ['page_id' => 'id']);
}

public function getTags()
{
    return $this->hasMany(Tag::className(), ['id' => 'tag_id'])
        //->viaTable('page_tag', ['page_id' => 'id']);
        ->via('pageTags');
}

if you change table name then it will have to fix in a few places

table prefix

Hi , in yii1 when we set table prefix in db component, in gii model generator we can search table without prefix and it generate model without prefix, but in yii2-gii it's diferance.
if it's posible add this abiality to yii2-gii

Option in Gii to select column of composite foreign key to use for naming getter in model

Lets say I have a table Project with a composite foreign key with two columns (account_id,created_by) to another table User. In such a case Gii uses the name of the FIRST column of composite key for a getter in the Project class:

public function getAccount1()
{
    return $this->hasOne(User::className(), ['account_id' => 'account_id', 'id' => 'created_by']);
}

But in reality the getter needs to be named after the LAST column in the composite foreign key:

public function getCreatedBy()
{
    return $this->hasOne(User::className(), ['account_id' => 'account_id', 'id' => 'created_by']);
}

So it would be nice to have an option in Gii interface to select which column of composite foreign key to use for naming getters (first or last).

Can't access the page when the table related contains underscores

I fooled around and created 3 tables :

test_with_underscore
test_underscore
testnoscore

The generators creates the files correctly for all 3 tables but when I try to access the page, only testnoscore shows up. The other two show an error, for test_underscore it will be :

An Error occurred while handling another error:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: spa/error' in /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/base/Controller.php:122
Stack trace:
#0 /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('error', Array)
#1 /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/web/ErrorHandler.php(80): yii\base\Module->runAction('spa/error')
#2 /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/base/ErrorHandler.php(101): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#4 {main}
Previous exception:
exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "testUnderscore".' in /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/base/Module.php:461
Stack trace:
#0 /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('testUnderscore', Array)
#1 /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 /usr/local/var/www/wip/mrvyii/web/index.php(12): yii\base\Application->run()
#3 {main}

Next exception 'yii\web\NotFoundHttpException' with message 'Page not found.' in /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/web/Application.php:96
Stack trace:
#0 /usr/local/var/www/wip/mrvyii/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /usr/local/var/www/wip/mrvyii/web/index.php(12): yii\base\Application->run()
#2 {main}

The DB is MySQL and the table scheme has 3 elementary columns (id, col1, col2).

generate the fields in _form.php file in the crud generetor based on the rules for the model and not the database table

specially since sometimes I change the rules of the model before generating the crud. Some use cases

[['file'], 'file'], // the form this will be a text input because on the column type is varchar
['active', 'boolean'], // will be a text input because the column type is int(1)
['delivery_date', 'date'],  // will genereate text input
['amount', 'integer'], // will genereate text input, it can easily generate an input('number') instead
['email', 'email'], // will genereate text input, it can easily generate an input('email') instead
['category_id', 'exist', 'targetClass' => Category::className()], // another text input, a select would be much more useful
// on the other hand, created_at and updated_at will be generated even if they are not on the rules.

V2.0.4 Model Generator in Oracle error

V2.0.4 "Model Generator" in Oracle error (YII2 v2.0.6)

PHP Fatal Error โ€“ yii\base\ErrorException
Maximum execution time of 120 seconds exceeded

V2.0.3 normal

Excuse me, is this the bug, or is it the problem for me.

Can't run a gii command more than once from my own command

I was writing a console command that would generate all my models crud :

foreach ($models as $model) {
          $this->run("gii/crud", [
                'controllerClass' => 'backend\\controllers\\' . $model . 'Controller',
                'modelClass' => 'common\\models\\' . $model,
                'viewPath' => 'backend/views/' . strtolower($model),
                'enableI18N' => 1,
                'messageCategory' => 'backend',
                'searchModelClass' => 'backend\\search\\' . $model . 'Search',
                'baseControllerClass' => 'backend\\controllers\\Controller',
                'template' => 'adminlte',
                'interactive' => 0
            ]);
}

in the second loop, the call fails with the following error:

Exception 'yii\base\InvalidConfigException' with message 'Unsupported configuration type: object'

in /private/var/www/flycarrent/vendor/yiisoft/yii2/BaseYii.php:350

Stack trace:
#0 /private/var/www/flycarrent/vendor/yiisoft/yii2-gii/Module.php(117): yii\BaseYii::createObject(Object(yii\gii\generators\model\Generator))
#1 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/Controller.php(139): yii\gii\Module->beforeAction(Object(yii\gii\console\GenerateAction))
#2 /private/var/www/flycarrent/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('crud', Array)
#3 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('crud', Array)
#4 /private/var/www/flycarrent/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('gii/crud', Array)
#5 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/Controller.php(183): yii\console\Application->runAction('gii/crud', Array)
#6 /private/var/www/flycarrent/console/controllers/GiiAllController.php(97): yii\base\Controller->run('gii/crud', Array)
#7 [internal function]: console\controllers\GiiAllController->actionIndex()
#8 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#9 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#10 /private/var/www/flycarrent/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('', Array)
#11 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('', Array)
#12 /private/var/www/flycarrent/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('gii-all', Array)
#13 /private/var/www/flycarrent/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('gii-all', Array)
#14 /private/var/www/flycarrent/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#15 /private/var/www/flycarrent/yii(27): yii\base\Application->run()
#16 {main}

I pin pointed the problem being located at this line : https://github.com/yiisoft/yii2-gii/blob/master/Module.php#L115
where $this->generators gets overwritten and gets filled with objects instead of configuration arrays.

I think we should add a new private property and keep a copy of the original $generators value in init() and reset $generators back to its original value in resetGlobalSettings() which is called at the end of beforeAction()

new Typeahead version bump

Hello,

Since there is a new Typeahead version 0.11 released, and some other libraries use it already, there is an incompatibility when yii-gii is included.
https://github.com/twitter/typeahead.js/releases/tag/v0.11.1

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for 2amigos/yii2-type-ahead-widget ~1.1 -> satisfiable by 2amigos/yii2-type-ahead-widget[1.1].
    - yiisoft/yii2-gii 2.0.4 requires bower-asset/typeahead.js 0.10.* -> satisfiable by bower-asset/typeahead.js[v0.10.5].
    - Conclusion: remove bower-asset/typeahead.js v0.10.5
    - Installation request for yiisoft/yii2-gii * -> satisfiable by yiisoft/yii2-gii[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4].

Can you already use the new version? some event names changed, but very useful others like changed were added.

Thank you!

Use Schema Name option missing from gii model generator

I do not wish to have the schema name/database name added to my class name when generating relation classes. I believe this was the older functionality. I tracked down the fix needed to give the user the option and it appears when the "useSchemaName" option was added to the gii Generator somebody forgot to update the view in vendor/yiisoft/yii2-gii/generators/model/form.php to include the line.

echo $form->field($generator, 'useSchemaName')->checkbox();

Adding that one line in vendor/yiisoft/yii2-gii/generators/model/form.php will give the user the option to include or not the schema name in class generation. The label and hints were already coded.

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.