giix

giix is gii Extended, a code generator for Yii PHP framework.
175 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.1 is here. It fixes the issue #23.

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 giix

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

#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!

#8903 report it
freddy Alarcon at 2012/07/06 12:44pm
yii code template bootstrap español

"http://dl.dropbox.com/u/47099316/yii/bootstrap.rar"

#8899 report it
fr0d0z at 2012/07/06 08:49am
Re: giiX relations

@olivier.marian: relations are automatically built using InnoDB / your DB's specified relationships. So if you set up the relationships in the database, things will work fine. Also, please note we're trying to keep support questions on the forum thread as much as possible. Thanks!

#8889 report it
olivier at 2012/07/06 06:25am
Bravo (Edited)

Hello, first thank you very much for this extension that helps start with iii and have a nice app quite fast.

EDITED: I have a question though, and moved it to the forum here

Thank you again for your work, and your help. best regards. Olivier

#8714 report it
Rodrigo Coelho at 2012/06/20 05:09pm
@evan108108

Please open a new issue and send as much information as possible so I can work on the bug. Thanks!

#8708 report it
evan108108 at 2012/06/20 10:18am
Using the version from this page

Yeah I am using version 1.9.1 downloaded from this page

#8706 report it
Rodrigo Coelho at 2012/06/20 10:03am
@evan108108

Are you using the trunk version? If so, please download giix from this page and install again.

#8704 report it
evan108108 at 2012/06/20 09:59am
Can't get the CRUD generator working.

I continually get this error:

Property "CPhpMessageSource.extensionBasePaths" is not defined.

Model generation works fine. This is a CRUD issue and it happens on preview.

Any help solving this would be great.

#8485 report it
warden at 2012/06/06 06:18pm
github

YEAH! perfect! at last :-) imho all yii plugins should be moved to github :-)

Leave a comment

Please to leave your comment.

Create extension