Yii 1.1: awegen

Code generator for Yii (with optional bootstrap support)
37 followers

awegen is an awesome code generator for Yii framework.
awegen borrows goodies from giix and gtc.

What It Does?

  1. Generates textarea for text db type
  2. Generates textarea with markitp editor for longtext db type (Uses markitup widget)
  3. Generates checkbox for boolean db types
  4. Uses JToggleColumn for boolean types in Admin/CGridView (Uses JToggleColumn extension)
  5. Generates fields with Datepicker for date db type
  6. Generates fields with Datetimepicker for time, datetime and timestamp db type (Uses datetimepicker widget)
  7. 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)
  8. Guesses e-mail fields by field names and adds e-mail validation for forms and mailto links for views
  9. Guesses image fields by field names and tries to display the image in views
  10. Guesses url fields by field names and adds url validation for forms and creates links for views
  11. Guesses password fields by field names, generates password fields for them in forms and hides them from non-admin users in views
  12. Guesses createtime and updatetime fields and adds proper timestamp behaviour to them
  13. Uses Activerecord-relation-behavior to handle all kinds of relations
  14. Creates pulldown menu for one-to-many and one-to-one relations
  15. Creates checkboxes for fields with many-to-many relations
  16. Keeps generated code in abstract base model so that regeneration doesn't overwrite user changes
  17. 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)
  18. 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 19 comments

#15906 report it
Diego Felix at 2013/12/28 09:12am
generate CRUD problem

I tried to generate the CRUD, but when I clicked "Preview", I received a page with this text:

render('index', array( 'dataProvider' => $dataProvider, )); } public function actionView($id) { $this->render('view', array( 'model' => $this->loadModel($id), )); } public function actionCreate() { $model = new TpContato; if (isset($_POST['TpContato'])) { $model->setAttributes($_POST['TpContato']); try { if($model->save()) { if (isset($_GET['returnUrl'])) { $this->redirect($_GET['returnUrl']); } else { $this->redirect(array('view','id'=>$model->

What's wrong?

I generated the models.

Application log, last trace:

Querying SQL: SHOW CREATE TABLE tp_contato in /home/bill/workspace/testdrive/index.php (13)

#13426 report it
bmac at 2013/05/28 06:31pm
Fatal error: Call to undefined method Awecms::getPrimaryKeyColumn()

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....

#11250 report it
le_top at 2013/01/01 11:45am
Issue

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.

echo "<?php echo CHtml::link(Yii::t('app', Awecms::pluralize('Sub-Page', '" . ucfirst($key) . "', count(\$model->{$key}))), array('" . $controller . "'));?>";
#10804 report it
The Zohan at 2012/11/25 12:21pm
Unable to resolve the request "gii/AweModel".

I had this error and sorted it by turning off seo urls, use plain old index.php?r=gii

#10636 report it
xtranophilist at 2012/11/09 01:59pm
Using text editor other than Markitup

@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.

#10620 report it
Mohammad Shahid at 2012/11/08 10:13am
Text Editor

Hi, how we can implement tinymce text editor with longtext type of columns.

#10131 report it
anilherath at 2012/10/05 02:18pm
Php version

You are correct. My php version is 5.2. Thank you and sorry for the inconvenience.

#9908 report it
xtranophilist at 2012/09/21 02:08am
Looks like PHP version incompatibility

@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.

AddType application/x-httpd-php53 .php
#9902 report it
anilherath at 2012/09/20 08:25am
Can not create CRUD

I am receiving this error while creating CRUD;

PHP warning

include(self.php) [function.include]: failed to open stream: No such file or directory

#8941 report it
luk1999 at 2012/07/09 07:18am
Bug in class AweCrudCode in function generateGridViewColumn

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):

$relatedModelName = get_class($relatedModel);
#8853 report it
Madi at 2012/07/04 03:46am
Unable to resolve the request "gii/AweModel".

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:

'import' => array
    (
        'application.models.*',
        'application.components.*',
        'application.modules.user.models.*',
        'application.modules.user.components.*',
        'application.modules.srbac.controllers.SBaseController',
        'application.extensions.awegen.components.*',
    ),
    'modules' => array
    (
        // uncomment the following to enable the Gii tool
       'gii' => array
        (
            'class' => 'system.gii.GiiModule',
            'password' => 'password',
            'generatorPaths' => array
            (
                'ext.awegen',
            ),
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters' => array('127.0.0.1', '::1'),
        ),
        ...
     ),
         // application components
    'components' => array
    (
        // uncomment the following to enable URLs in path-format
 
        'urlManager' => array
        (
            'urlFormat' => 'path',
            'showScriptName' => false,
            'caseSensitive' => false,
            'rules' => array
            (
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            ),
        ),
        ...
    ),

Thank you in advance.

#8775 report it
xtranophilist at 2012/06/26 04:20am
Updated

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.

#8724 report it
H Samuels at 2012/06/21 05:37pm
No Awegen Options In GII

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:

// autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.extensions.awegen.components.*',
        'ext.giix.giix-components.*', // giix components
    ),
 
    'modules'=>array(
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'password_here',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('127.0.0.1','::1'),
            'generatorPaths' => array(
                'ext.awegen',
                'ext.giix.giix-core',
                ),
        ),
        'admin',
    ),

Thanks for any help!

#8653 report it
Girish at 2012/06/17 08:09am
Error

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 *

#8613 report it
sepu at 2012/06/14 06:50am
Return me this erro

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 *

#8530 report it
xtranophilist at 2012/06/11 02:00am
Import Components

@UncleSym
Maybe you forgot to import components. Awecms.php happens to be in 'application.extensions.awegen.components.*'. Add it to your imports section in config/main.php as 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.

#8529 report it
UncleCoder at 2012/06/10 10:40pm
error

I have an error when trying to use AweCrud Generator:

include(Awecms.php): failed to open stream: No such file or directory
#8528 report it
xtranophilist at 2012/06/10 05:42pm
Fixed dependency on user module

@thyseus Thank you very much, that has been fixed. The generator now looks if the user module is available.

#8525 report it
thyseus at 2012/06/10 12:15pm
nice so far, but it depends on a user module

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 to leave your comment.

Create extension
Downloads