awegen is an awesome code generator for Yii framework.
awegen borrows goodies from giix and gtc.
What It Does? ¶
- Generates textarea for
text db type
- Generates textarea with markitp editor for
longtext db type
(Uses markitup widget)
- Generates checkbox for
boolean db types
- Uses JToggleColumn for
boolean types in Admin/CGridView
(Uses JToggleColumn extension)
- Generates fields with Datepicker for
date db type
- Generates fields with Datetimepicker for
time, datetime and timestamp db type
(Uses datetimepicker widget)
- Allows easy addition of access control templates in the generator
( Users can add templates into AweCrud/templates/default/auth folder and they will be listed in the CRUD generator)
- Guesses e-mail fields by field names and adds e-mail validation for forms and mailto links for views
- Guesses image fields by field names and tries to display the image in views
- Guesses url fields by field names and adds url validation for forms and creates links for views
- Guesses password fields by field names, generates password fields for them in forms and hides them from non-admin users in views
- Guesses createtime and updatetime fields and adds proper timestamp behaviour to them
- Uses Activerecord-relation-behavior to handle all kinds of relations
- Creates pulldown menu for one-to-many and one-to-one relations
- Creates checkboxes for fields with many-to-many relations
- Keeps generated code in abstract base model so that regeneration doesn't overwrite user changes
- Guesses identification column for models and uses them in headings and breadcrumbs
(Looks for following fields in order of priority - name, title, slug, any field with name in its name, first non-numeric field, primary key)
- Handles parent-child relationship of items among same model
(Allows an item to be parent/child of any other items from the same table but not itself)
Installation ¶
Download from https://github.com/xtranophilist/awegen/zipball/master
Extract the content of the archive to extensions directory and rename the top level directory from extrancted content to awegen.
Add the path of awegen to generatorPaths section in gii module configuration in config/main.php
'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'password',
'generatorPaths' => array(
'ext.awegen',
),
),
...
),
Add the components required to your imports section
'import' => array(
...
'application.extensions.awegen.components.*',
),
Usage ¶
Browse to /gii, login and select AweModel Generator to create Model and then AweCrud to generate Controller and Views.
Use * for table name in Model generator to preview all models. Generate all or selectively.
Resources ¶
Total 18 comments
I received the above error. I then went to \awegen\components\Awecms.php and changed getPrimaryKey to getPrimaryKeyColumn on line 19 seeing that it had been refactored on git and everything works fine.
I am surprised that I am the first to post this, being that I am not nearly as good as most people that post, I hope I am not messing anything up....
Hi Using a base for the models is excellent (I can't disagree with what I did in other contexts).
There is an issue with some parts of the generator. Here is one, I got the following line generated for the CRUD where it refers to AweCms::pluralize which does not exist.
I had this error and sorted it by turning off seo urls, use plain old index.php?r=gii
@Mohammad Shahid: Look for the text
$this->widget('EMarkitupWidget'in generateField() method in AweCrudCode.php Modify that line to use any editor of your choice.Hi, how we can implement tinymce text editor with longtext type of columns.
You are correct. My php version is 5.2. Thank you and sorry for the inconvenience.
@anilherath I am not sure about the problem. My guess is your PHP version is older than 5.3. If your server has multiple versions installed and 5.3 isn't the default one, you can force the server to use PHP v5.3 by adding the following line to your .htaccess file in the root folder of your project.
I am receiving this error while creating CRUD;
PHP warning
include(self.php) [function.include]: failed to open stream: No such file or directory
There's a bug in function generateGridViewColumn(). Relations columns are not generated propertly in /views/[controller]/admin.php. You need to set variable $relatedModelName. Just add this line in AweCrudCode.php (between line 286 and 287):
I've installed the extension as described. When I get to the gii page and I click on "AweCrud Generator" or "AweModel Generator" I get the error Unable to resolve the request "gii/AweModel". The other normal gii functions work perfectly.
I am using the following config: Apache/2.2.22 (Win32) PHP/5.3.10 Yii Framework/1.1.10 and a .htaccess file in the root directory: Following is my config/main.php file:
Thank you in advance.
awegen has been updated. To prevent the confusion, I've included components in the git repo too. Fix by sam to bulk-generate models from all tables has also been pulled.
Hi,
I've installed the extension as described, but I'm still not seeing any new options in Gii. Here is an excerpt from my config file:
Thanks for any help!
I got the following error while genertaing the AweCRUD
AweCMS CRUD Generator Fields with * are required. Click on the highlighted fields to edit them.
Model Class *
When I click in Gii on menu "AweCrud Generator" return me this error:
on AweCMS CRUD Generator
Fields with * are required. Click on the highlighted fields to edit them.
Model Class *
@UncleSym
Maybe you forgot to import components.
Awecms.phphappens to be in'application.extensions.awegen.components.*'. Add it to your imports section inconfig/main.phpas instructed in installation section above.Cloning from the github doesn't get you the dependencies. You have to download from the downloads page or from here.
I have an error when trying to use AweCrud Generator:
@thyseus Thank you very much, that has been fixed. The generator now looks if the user module is available.
Everything works, but the generated code depends on a user management module.
views/-model-/view.php line 23 has a Yii::app()->getModule('user') which is not available for a default yii application.
Thats the only problem i have found so far, its a GREAT extension and combines (and cleans up) most of the features of gtc and giix ! +1 ;)
Leave a comment
Please login to leave your comment.