Yii 1.1: giix

giix is gii Extended, a code generator for Yii PHP framework.
187 followers

Overview

giix is gii Extended, a code generator for Yii PHP framework.

giix is inspired and based on gii-template-collection (gtc), by Herbert Maschke (thyseus).

giix is free software and is dual-licensed under the terms of the new BSD License and under the terms of GNU GPL v3. See the LICENSE file.

Links

Forum discussion for giix
giix on GitHub

Watch giix on GitHub Fork giix on GitHub

Starting with Yii? Read The complete beginner's study guide for the Yii Framework

Latest news

giix 1.9.2 is here. It adds out-of-the-box support for giic.

Acknowledgements

giix is inspired and uses code from Yii PHP framework and gii-template-collection. Many thanks to Qiang Xue, Herbert Maschke and the contributors of these software.

Features

giix extends Yii's gii by providing:

  • Proper handling of related model attributes, rendering appropriate form fields based on relation type.
  • More support for HAS_MANY and MANY_MANY relations.
  • Native support for saving MANY_MANY relations with the new method GxActiveRecord::saveWithRelated.
  • Native support for saving multiple (related or not) records with the new method GxActiveRecord::saveMultiple (this method has known bugs, avoid using it).
  • Automatic string representation for a model via GxActiveRecord::representingColumn() and GxActiveRecord::__toString().
  • Better i18n support and easier to maintain: support to active record labels. You change the label once in the model and it is automatically updated in the views. This is especially useful for plurals.
  • Out-of-the box i18n support by using Yii::t().
  • Appropriate form fields are rendered based on model attribute/table field data type.
  • Separated model and basemodel. Basemodel can be regenerated without overwriting your code in the model.
  • Smart methods can query your database for just the needed data (usually the primary key and the field with the string representantion), avoiding manual setup or a "select *".
  • Extensive use of default method parameters. Appropriate data is found automatically.
  • Some (incipient) support for tables with composite primary keys.
  • Generated code is completely free from styling and formatting. Your CSS controls the presentation.
  • Generated code is (almost) free of comments.
  • Well documented and commented source code. Ohloh says that 40% of the lines in the code are comments! You can understand and modify anything you want.

And a lot more! Read the CHANGELOG file and the (richly commented) source code to fully leverage giix's power.

Some of these features come from gtc.

Warnings

giix is not fully tested now, so please test your application and be careful using it.
giix is still in development. Some changes may break backwards compatibility.

Are you upgrading? Please don't forget to read the UPGRADE file for instructions!

Some users reported problems extracting the files from the archive.
Please download the free 7-zip version 9.20, it is reported to work well.

Installation and upgrading

Please see INSTALL and UPGRADE files for instructions.

Please check the README file for more information.

Related wiki pages

Extensions based on/for or related to giix

  • giix-haml: Extends the giix extension adding Haml templates and more.
  • e-xgen: extjs crud generator.
  • manymanyajaxcrudadmin: giix templates for ajax CRUD code generation of a MANY_MANY Model relationship.
  • foundation4giix: Templates for using Foundation 4 with Yii and optional giix templates if you're a giix fan.
  • giic: Toolset for running Gii (and giix) on the command line.
  • monthpicker: Yii extension wrapping the jQuery UI Monthpicker Widget from Julien Poumailloux (with giix integration).

Apps powered by giix

Reactions

Already using giix?

Show the love! Show how you love giix on the forum and on this extension page
Upvote! Upvote giix

Made in Brazil Made in Brazil by mentel (Rodrigo Coelho)

Icons by famfamfam.com

Total 20 comments

#17794 report it
rashmani at 2014/07/23 03:08am
Separated Controller and Giix version

Hi there!

First of all thanks for Giix, unvaluable, also as learning tool.

@Diego Felix: what you can do is to separate Controller's Actions, possibly sharing Actions amongst controllers thus improving code reusability. Fundamentals are here: http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#action. Pay attention when you need to call Controller's methods from your Action, you may need to execute this before:

// get controller
        $controller = $this->getController();

@Rodrigo: is there any chance to have an easy way to get Giix running version? Something like displaying it in generator pages... I haven't update Giix in a long time and found myself naked when looking for current installed version... Apart from this, great job whatsoever!

rash*

#16691 report it
yanhui at 2014/03/19 10:11pm
Awesome

Yes, it saved me a lot of time, too. Thank you Rodrigo Coelho and all the contributors!

#16439 report it
Diego Felix at 2014/02/23 08:28am
separated controller and basecontroller

Does anyone knows an implementation of a separeted controller and basecontroller like to the model in giix:

  • Separated model and basemodel. Basemodel can be regenerated without overwriting your code in the model.

anyone knows?

#15536 report it
Hesam at 2013/11/19 10:48am
GxController extends Controller

I use yiiinitializer and I installed Gix. After crud creation, I've got an error that it cannot include controller.php, so I have to change the above line to GxController extends CController.

#14981 report it
Rafalsky.com at 2013/09/26 04:13am
You have an error in code

You have an error in code in method GxActiveRecord::saveMultiple();

You try to start transaction by this: $this->getDbConnection()->beginTransaction()

But this is a static method so variable $this is not declared :)

#14287 report it
Rodrigo Coelho at 2013/08/01 09:53pm
@schmunk

Great idea! I'll take a look at it.

#14285 report it
schmunk at 2013/08/01 06:02pm
Toolset for running Gii on the command line

Hello,

I've just released giic to run Gii on the command line. See the README for infos about running giix generators with it.

Best regards, schmunk

#14113 report it
Elecen at 2013/07/19 09:14pm
Bug in saveMultiple

Hi guys, just installed and about to start using Giix again (after a looong time), really nice job by the way. I noticed in the GxActiveRecord class the saveMultiple function is static and in the function I see a lot of $this->....

If I get the chance to fix it I'll send a patch.

Awesome job, keep it going! xD

#13199 report it
fleuryc at 2013/05/13 09:51am
MANY MANY relation with data

Hi!

Just a question : can I use saveWithRelated for a MANY_MANY relation with data. For instance :

Person(int id)-Seen(int id_person,int id_movie,date date,bool liked)-Movie(int id)

Can I use saveWithRelated to save one person with all the movies he has seen and the relation data (date and liked wich cannot be null)?

If not, how to do it nicely?

Cheers!

#12994 report it
eholsinger at 2013/04/26 12:47pm
use extensionPaths not extensionBasePaths

For "Property "CPhpMessageSource.extensionBasePaths" is not defined.", there is no property "extensionBasePaths", based on yii-1.1.13.e9e4a0, framework/i18n/CPhpMessageSource.php:

/**
     * @var array the message paths for extensions that do not have a base class to use as category prefix.
     * The format of the array should be:
     * <pre>
     * array(
     *     'ExtensionName' => 'ext.ExtensionName.messages',
     * )
     * </pre>
     * Where the key is the name of the extension and the value is the alias to the path
     * of the "messages" subdirectory of the extension.
     * When using Yii::t() to translate an extension message, the category name should be
     * set as 'ExtensionName.categoryName'.
     * Defaults to an empty array, meaning no extensions registered.
     * @since 1.1.13
     */
    public $extensionPaths=array();

so the config should actually be

'messages' => array (
      // Pending on core: http://code.google.com/p/yii/issues/detail?id=2624
      'extensionPaths' => array(
        'giix' => 'ext.giix.messages', // giix messages directory.
      ),
    ),

This might have solved @evan108108's issue. Hopefully it can help someone else.

#11784 report it
bryglen at 2013/02/03 10:19pm
@Luiz

Thanks for your codes.

like I've said many people don't know how to used giix properly :)

I've still seen a lot of people don't know how to override and inherit and it's great if you put it on your extension.

#11757 report it
Luiz at 2013/02/01 10:13pm
Merging BaseModel and Model configurations

@bryglen, I never change the BaseClass.

I generate constantly new BaseClasses and I almost never lose the settings of the child classes. Of course I always do a basic review. To this I do a merge (CMap::mergeArray()) of the corresponding function of the parent class to the child class.

See this example, I have an UserBase.php (intact ) and my User.php:

class User extends UserBase{
 
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
 
    public function relations()
    {
        return CMap::mergeArray(parent::relations(),
            array(
                'organizations' => array(self::MANY_MANY, 'Organization','user_organization(user_id, organization_id)'),
            )
        );
    }
}

In case of conflict you can remove an entry from the BaseModel without editing it using the function array_diff():

public function rules()
    {
        return CMap::mergeArray(array_diff(
               parent::rules(),
               array(
                   array('name, password, password_strategy, email, create_time', 'required'),
               )
            ),
            array(
                array('name, password, email', 'required', 'message' => Yii::t('validation', 'Please insert your {attribute}.')),
                array('password_strategy, create_time', 'message' => Yii::t('validation', '{attribute} are null!')),
            )
        );
    }

This code remove the rule from parent rules function:

array('name, password, password_strategy, email, create_time', 'required')

That way I avoid the conflict of two messages appear for the same validation error.

Hope this help

#11339 report it
bryglen at 2013/01/07 03:02am
Hi Rodrigo. Suggestion regarding giix.

Can you add a tutorial how people will override and inherit without modifying the BaseClass

I've still seen a lot of people don't know how to override and inherit and it's great if you put it on your extension.

#10965 report it
cappadochian at 2012/12/06 08:27pm
Property "GiixModelCode.relations" is read only.

by model generation.

Source File

C:\wamp\www\pr3\protected\extensions\giix-core\giixModel\GiixModelCode.php(67)

00067: $this->relations = $this->generateRelations();

what have I done wrong...?

thanks!

#10945 report it
Athos at 2012/12/05 08:28pm
A quick way to select only the changed Base classes
checkBaseOverwrite = function() {
    $(\"table.preview\").find('input').attr('checked', false);
    $(\"tr.overwrite:contains('\_base\')\").css('background-color', '#faa').find('input').attr('checked', true);
}
 
xcheckBaseOverwrite = $('<a href=\"javascript:void(0)\" onClick=\"checkBaseOverwrite()\">Base Overwrite</a>');
 
$('table.preview').before(xcheckBaseOverwrite);
#10942 report it
Rodrigo Coelho at 2012/12/05 11:09am
Re: Feature Suggestion

Agreed, @ktwbc. This feature will be present in a future release of giix. Thanks for the suggestion!

#10940 report it
ktwbc at 2012/12/05 09:46am
Feature Suggestion

The Giix extension is nice, but one thing that would help would be a quick way to select only the changed Base classes. When I modify my tables, and have to regenerate with Giix, it's showing all the child classes in red (of course because that's where my model logic is), but I have to hunt for the /Base versions throughout the list. You need a "Select All (Changed) Base" button.

#9936 report it
nlac at 2012/09/23 06:45pm
javascript error dropped by the autoComplete widget

hi, there's a js error "TypeError: g.nodeName is undefined" dropped by the CJuiAutoComplete widget in giixModel/views/index.php, preventing the suggestion of the model class name. Latest Yii 1.1.12 is used.

I made a quick fix, replacing the row
$(this).val($(ui.item).val());
to
$(this).val(ui.item.value);

Great extension btw!

#9690 report it
Roman Solomatin at 2012/09/03 05:17pm
Tribute to Author

Thanks you! This is an excellent extension.

#9200 report it
Steven Ly at 2012/07/27 03:10pm
Awesome

First of all, this is an awesome extension. It saved me a lot of time (and head scratching). Thumbs up!

Leave a comment

Please to leave your comment.

Create extension