- Overview
- Links
- Latest news
- Acknowledgements
- Features
- Warnings
- Installation and upgrading
- Related wiki pages
- Extensions based on/for or related to giix
- Apps powered by giix
- Reactions
- Already using giix?
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
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 ¶
- How to obtain a grammatically correct translation of the model name in giix-generated view files
- Radio Button List with enum values for column of type ENUM >+> incorporate into giix
- Drop down list with enum values for column of type ENUM >+> incorporate into giix
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 ¶
- Point of Sales Brys demo(http://demo.pointofsalesweb.com/)
- Add yours! Let me know at rodrigo at giix.org.
Reactions ¶
- Trinidev - see in english.
- Nyúlkál, piszkál, szétszed - see in english.
Already using giix? ¶
Show how you love giix on the forum and on this extension page
Upvote giix
Made in Brazil by mentel (Rodrigo Coelho)
Icons by famfamfam.com
Assumed fixed dir!
Although this extension looks really good, its author assumed that everyone will be putting 'giix-components' and 'giix-core' folders directly under 'protected/extensions' folder, which is rather bad idea. Any attempt to put this extension to a separate subfolder like 'protected/extensions/giix' fails, even if one update correctly configuration file, according to INSTALL file instructions - Gii will fail when trying to access Giix* elements of it, saying that specified alias is invalid.
An ability to put this extension to an separate folder is especially essential since it contains files like INSTALL or LICENSEE in root folder, which could run into conflict with similar files from other extension that also does not allow users to put them into separate folder. This should be fixed IMHO.
Re: Assumed fixed dir!
Hello Trejder,
Yes, the directories must be put inside 'protected/extensions'.
There is currently no plan to change this, but if you think it is important, you can open a ticket at Google Code for this enhancement. With enough support (and time) this can be changed.
And the text files aren't needed in the live project directory, you just need the two directories.
useful
i used giix in 2 projects for now .. and i am planning to use it again
i really like the features it comes with ..
thanks for your efforts on this ext.
Update
Dear,
I've been very busy lately, but I hope I can resume working in giix soon.
There are some pending bugfixes (some are already fixed in trunk, check there!) and the roadmap is huge. Great things will come.
Please keep the comments, suggestions and bug reports (and patches if you can) coming!
Thank you,
Rodrigo Coelho - mentel
@muaid
@muaid Thank you very much! :)
New version: giix 1.5
And there's a new version!
Thank you all for the support :)
New version: giix 1.6
All known bugs fixed.
More automatic magic.
More flexibility.
More support to composite PK tables (but still incipient support).
giix is evolving fast. Stay tuned!
@kaliwangansyah
Thank you for your kind words!
If you have suggestions, they are welcomed :)
Thanks for all the votes!
giix 1.7 is here!
All known bugs were fixed:
The code from Yii was updated to the version 1.1.7 (r3135) of the framework.
More to come :)
I feel you will like it
Dear,
giix 1.8 is out!
The improvements:
Don't forget that you must implement the "label" method on each AR that extends from GxActiveRecord when upgrading.
Download it right now!
Please use giix 1.7
Dear,
Please use giix 1.7 until some issues on 1.8 are solved (on 1.8.1 or 1.9).
Thanks for your consideration.
New version: giix 1.9
Dear,
giix 1.9 is here, and it gives you a smooth experience with active record and relation labels.
This new version improves the labels feature introduced in giix 1.8 and delivers the functionality with performance and flexibility. Give it a try!
I appreciate your votes, keep voting! :)
Don't forget that you must implement the "label" method on each AR model that extends from GxActiveRecord when upgrading. See the UPGRADE file for more information.
Error GxActiveRecord.php
Hi!
Spotted an error in GxActiveRecord.php.
On lines 542, 536 and 550 you check if($transacted) in the GxActiveRecord::saveRelated() method.
That variable does not exist in that context.
Also, it seems the transactions are handled in all the methods calling GxActiveRecord::saveRelated(). I don't think it even should be in there?
@ChessSpider - Re: Error GxActiveRecord.php
Hi ChessSpider!
Thanks for posting here.
You are correct: it was not needed there.
This issue is already fixed in the trunk. Fixed by revision 167.
You can replicate the changes made in that revision to your copy of giix. That will fix it for you until the next version of giix is out.
Note: Please don't update your copy of giix to the version in the trunk. It is unstable and also requires Yii 1.1.9, which is not released yet.
Seperate DeleteMap and InsertMap
Hi !
I want to log the changes done to MANY_TO_MANY related models. Which related items gets deleted or inserted.
With the current implementation I wasn't able to do that. As a quick-fix I made a GxActiveRecord::deleteMap() and GxActiveRecord::insertMap() method, which is being called in saveRelated().
Now I have the data I need to log which items gets added and which items are removed.
But perhaps you can implement a better way, via a OnRelatedUpdate() or OnRelatedDelete() Event or something.
--
I actually have undo these changes, but I still would like to log which records GxActiveRecord deletes or inserts with a saveRelated() call.
@ChessSpider - Re: Separate DeleteMap and InsertMap
You can use Yii standard events onBeforeSave/onAfterSave and onBeforeDelete/onAfterDelete (you will need to disable the batch mode to track deletes) on the pivot model.
It is all there already :)
Almost what I want,
Hi!
Thanks for the fast feedback.
It's close, but not exactly what I meant. That will generate a new log-item per insert/delete, but I want to track the changes done per change.
I need to have one log-item for all inserts, one log-item for all deletes per saveRelated call. If I somehow easily could get the $deleteMap and $insertMap in insertRelated(), together with the pivot-model classname, I would be a happy man.
@ChessSpider
Hi ChessSpider,
Please open a ticket and I'll think in something.
Thanks!
giix 1.9.1 and THANK YOU!
Guys, you are awesome.
A few days ago I saw that giix is currently ranking first as the most upvoted extension for Yii!
I'd like to thank you very much for your feedback :)
And there is giix 1.9.1, with a fix for the issue #23.
This issue was already fixed in the trunk, but I have decided to make this release until the new version is not ready.
And the version 2.0 is being carefully prepared. Stay tuned!
Cannot extract on Windows
Hi mentel,
I wanted to update to your latest version 1.9.1, but it seems 7-Zip fails to untar your file on Windows. After un-taring I have an file instead of an folder. Same issue with 1.9,
giix-1.7.tgz is extracting fine.
Can you please provide a zip or check if you changed some gzip options from 1.7?
Regards
Sebastian
Re: Cannot extract on Windows
Hi sieppl,
It was archived using tar under Linux, like the other files. It works for me with tar in a different Linux box and with RAR in a Windows machine.
I uploaded a zip file for you.
Anyone else with this issue?
corrupt
winrar is complaining about the archives being corrupt.. where can I download the zip?
Try 7zip
I had no problems to unzip/untar the archives using 7-zip (http://www.7-zip.org) on Windows.
7zip
7zip works, although i prefer winrar :)
Re: corrupt
@wisp
I use RAR, too and it is ok here.
Could you please tell me the version of your RAR?
@max-300
Could you please tell me the version of your working 7zip?
@sieppl
If you are reading, could you please do the same for the version of 7zip you had problems with?
Thanks
7zip
I used 9.07 beta. But I just upgraded to 9.20 and it works too.
Note: When you unzip and untar giix-1.9.1.tgz, you get a file named giix-1.9.1
Click again on this file and select unzip to (folder) -> then you will get the content of the package.
@max-300
Thanks!
7-zip 9.20 works fine
@mentel. Did an upgrade in the meantime. So I cannot tell which version caused the problem. Now I am using 9.20 and it works after testing again today (see comment of max-300).
@sieppl
Very nice. Thank you!
Thanks
You did a great job, congratulations! I've done two sites using giix hugs.
Extracting Problems
hi mentel,
this extension is just what I was looking for (according to descriptions).
but I have problems extracting it.
I tried with WinRAR (version 4.10, 64 bit on Window7), and get an 'archive is corrupt' error.
I tried 7-zip (version 9.20): extracted first the archive giix-1.9.1.tar from giix-1.9.1.tgz without problems. But when I extract giix-1.9.1.tar, there is only one file named ""giix-1.9.1"" in it.
I'd be happy for any suggestions?
@c@cba
Re: Extracting Problems
Hi c@cba,
Some commenters below reported that you can extract the files with 7zip version 9.20.
Please report back if you can't extract the files with the version above.
Extraction using 7zip 9.20
Hi mentel,
I was already using 7-zip 9.20 (see my comment below). In principle, it extracts without problems. But the result is a single file without any extensions.
Problem solved: While writing this comment, in particular the phrase 'without any extensions', I had the idea that this third file could also be a compressed file, but in disguise. And that led to the following solution (using 7zip 9.20):
In this last created folder, there are the files.
Note: I tried "Extract Here" on the extension-less file without adding the '.zip', it didn't work. But if you use "Extract files..." and then provide a folder name different from the name of the file, then it works without adding the '.zip' to the filename.
Oddly, this worked too (if you don't want to install 7zip and want to use WinRAR):
Now I can get to the fun part :) Thanks again for this extension!
@c@cba
Sorry I didn't read your comment correctly :)
Thanks for the detailed explanation! Other users will like it.
Please try renaming the initial file from .tgz to .tar.gz and check if WinRAR and 7-Zip will perform as expected. If you confirm this, I'll name the next versions like this.
Thanks!
@mentel
Hi mentel,
I changed the filename from
giix-1.9.1.tgz
togiix-1.9.1.tar.gz
.WinRar and 7zip behaved exactly like before: i.e. WinRAR didn't extract throwing 'corrupt file' error, and with 7zip I had to go through the steps 1-4 described below.
@c@cba
Thanks!
nice
Very nice. Thank you!
Twitter Bootstrap
IS there anyway that I can get Giix to generate twitter bootstrap views? This would really be cool. Or if anyone have some work around please do let me know..
@iScotts
It seems that the bootstrap extension does this for you.
thx
@mentel, thank u so much for the link, and thank u so much for your extension, i really learn a lot..
sql comment to Labels (generateLabelsEx)
public function generateLabelsEx($table, $className)
{ $labels=array(); $sql ="SELECT COLUMN_NAME, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '$table->name'"; $res = Yii::app()->getDb()->createCommand($sql)->query(); foreach ($res as $column){ if (!empty($column['COLUMN_COMMENT'])) $labels[$column['COLUMN_NAME']]= $column['COLUMN_COMMENT']; else $labels[$column['COLUMN_NAME']]= $column['COLUMN_NAME']; $labels[$column['COLUMN_NAME']]="Yii::t('app', '".$labels[$column['COLUMN_NAME']]."')"; } // For the relations. $relations = $this->getRelationsData($className); if (isset($relations)) { foreach (array_keys($relations) as $relationName) { $labels[$relationName] = null; } } return $labels; }
Please share your thoughts
Please leave a comment when you downvote, so the extension can be improved.
Thanks!
Cool!
Great extension!
It would be cool if it would generate the unit tests along with the CRUD controller class :)
production ?
Extension is great.
In README is written : giix is not production ready yet.
What does is mean :
1- it still buggy (i did not found bug using it for a few hours)
2- Performance is poor
3- you don't want to have people complaining it does not work the way it should
4- you plan it do to a lot more.
I'm asking because i plan to use it for medium traffic, complexe data structure websites.
Testing a lot (human + unit tests + automated tests (selenium)) will be enough to be condifent and use it in production ? (don't worry, i won't complain if it does not work properly).
Please advise me.
@seb7
Hi seb7,
Thanks for your kind words.
You can use it in production if you follow these comments and test your code.
Thanks for choosing giix!
Good luck in your project.
ok, thks
@mentel thank you.
So i'll use it :)
And thanks again for that extension :)
giix now in GitHub!
giix has a new home at Github: https://github.com/rcoelho/giix
Feel free to open issues, fork and send pull requests!
github
YEAH! perfect! at last :-)
imho all yii plugins should be moved to github :-)
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.
@evan108108
Are you using the trunk version?
If so, please download giix from this page and install again.
Using the version from this page
Yeah I am using version 1.9.1 downloaded from this page
@evan108108
Please open a new issue and send as much information as possible so I can work on the bug. Thanks!
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
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!
yii code template bootstrap español
"http://dl.dropbox.com/u/47099316/yii/bootstrap.rar"
Awesome
First of all, this is an awesome extension. It saved me a lot of time (and head scratching). Thumbs up!
Tribute to Author
Thanks you! This is an excellent extension.
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!
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.
Re: Feature Suggestion
Agreed, @ktwbc. This feature will be present in a future release of giix. Thanks for the suggestion!
A quick way to select only the changed Base classes
[javascript] 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);
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!
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.
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 _arraydiff():
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
@Luiz
Thanks for your codes.
like I've said many people don't know how to used giix properly :)
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.
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!
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
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
@schmunk
Great idea! I'll take a look at it.
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 :)
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.
separated controller and basecontroller
Does anyone knows an implementation of a separeted controller and basecontroller like to the model in giix:
anyone knows?
Awesome
Yes, it saved me a lot of time, too. Thank you Rodrigo Coelho and all the contributors!
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*
yii2
Hi!
Are you planning to upgrade giix to work in yii2?
Thanks!!
@nye.cat
I am working on a similar project for Yii2 called giiant... you may have a look.
Giix Crud Generator Error (1.9.2)
Hi, I downloaded last Giix tools, i've allready used in another proyects, but not this version.
I have an error when I try to use Crud Generator (Model Works fine), the problem is that page stop loading when starttin widget "zii.widgets.jui.CJuiAutoComplete", aprox on line 26-27.
I comment that line and add this before:
<?php echo $form->textField($model,'model', array('size'=>65)); ?>
It looks like a problem with the parms to the widget.
If I turn on the log, I see that the last entry is loading that widget ... and nothing more.
Any Idea ?
PS: I check that page encondig is "utf-8 w/o BOM" and windows.
Best Regards
seconding bryglen suggestion
please can you write a tutorial concerning how to overide the methods, am currently experiencing problem with rules() in model right now although i already submit a help on the forum
thanks for the extension
Fail to try it
Sorry if I so late to read it and give the comment. But I hope anyone could help me to fix my problem. I downloaded giix extension. I have followed the tutorial above. But I don't know why it doesn't work.
When I compiled it, the browser display CException that said : CActiveForm and its behaviors do not have a method or closure named "enumDropDownList".
Please, anyone could help me ? because this project very important to me. Thank you
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.