Yii Framework Forum: Giiant - Gii On Steroids - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Giiant - Gii On Steroids CRUD Generator

#1 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 14 March 2014 - 01:44 PM

Hi,

I just added the provider feature from gtc (Yii 1) to giiant.

Quote


In many cases you want to exchange i.e. some inputs with a customized version for your project. Examples for this use-case are editors, file-uploads or choosers, complex input widget with a modal screen, getting data via AJAX and so on.

With Giiant Providers you can create a queue of instances which may provide custom code depending on more complex rules. Take a look at some existing giiant providers.

Have a look at: https://github.com/s...k42/yii2-giiant


Best regards,
schmunk
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#2 User is offline   pieturp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-August 13

Posted 14 March 2014 - 04:18 PM

Unfortunately, I couldn't try it out :(

Installing it with

php composer.phar require schmunk42/giiant @dev


gave an error:

requirements could not be resolved to an installable set of packages.
  Problem 1
    - The requested package schmunk42/giiant could not be found in any version, there may be a typo in the package name.


Edit: Fixed it :)

php composer.phar require schmunk42/yii2-giiant @dev
instead of
php composer.phar require schmunk42/giiant @dev


Edit 2: No luck :(

You seem to have some conflicting ideas on namespacing :unsure:

I now get the following PHP error:
 PHP Fatal Error – yii\base\ErrorException	
Class 'schmunk42\giiant\Generator' not found


But trying to edit the configuration to use yii2-giiant also had no luck...

This post has been edited by pieturp: 14 March 2014 - 05:30 PM

0

#3 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 15 March 2014 - 09:33 AM

Thanks for your feedback, I fixed the README and updated master.
I was missing crud in the config here: schmunk42\giiant\crud\Generator


Please run


composer.phar update schmunk42/yii2-giiant


and let me know if it works now.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#4 User is offline   pieturp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-August 13

Posted 15 March 2014 - 11:00 AM

Yes. It works now :)

Looks very promising indeed. I'll check out more next week, as I'm planning to maybe write some custom providers of my own.
0

#5 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 15 March 2014 - 12:48 PM

Cool. For some inspiration about providers have a look at: https://github.com/s...lCrud/providers

I am looking forward about any feedback. I thought i.e. about using an interface or traits for providers, but found no real advantage so far.
Here's an example for a very app or project specific provider: https://gist.github....hmunk42/6641457
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#6 User is offline   pieturp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-August 13

Posted 24 March 2014 - 11:36 AM

Hi Schmunk,

Unfortunately, I didn't have the time to dig in custom providers, but I now have another problem:

Apparently there has been a change in the way objects are configured; after an Yii update, I suddenly get the error "Fatal error: Access to undeclared static property: Yii::$objectConfig" in my web.php config file.

It is caused by
\Yii::$objectConfig = [
	    // giiant provider configuration
	    'schmunk42\giiant\crud\providers\EditorProvider' => [
	        'columnNames' => ['description']
	    ]
	];


I searched the docs for how this configuration should look now, but couldn't really find anything :(
0

#7 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 24 March 2014 - 12:36 PM

This is due to a Yii 2 API change, see here for how to update the app config:
https://github.com/p...ig/web.php#L100

Corresponding guide section: http://stuff.cebe.cc...ults-class-wide
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#8 User is offline   Jonny 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 208
  • Joined: 26-December 11

Posted 24 March 2014 - 12:44 PM

Does Giiant have the same facilities Giix does for creating base models so if you ever need to change your DB schema you can just re-run Gii and it wont overwrite your code in the models?
0

#9 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 24 March 2014 - 01:27 PM

I haven't implemented this yet, but yes it's planned.
Would be nice if you could create an issue for this: https://github.com/s...2-giiant/issues


We'd need a custom template and a generator for the model.
I'd suggest an additional attribute "createModel" which could be set to false (checkbox).

For the CRUDs I thought about a base class and almost empty controller classes, similar to this Yii 1 solution from Mike (https://github.com/m...xcrudcontroller). But this could also be handled with a custom template, so it's optional - and also one additional attribute for the generator "createController".


btw: I am working on Gii from the command line: https://github.com/y.../yii2/pull/2789 which also would fit nicely into your workflow, I guess.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#10 User is offline   pieturp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 09-August 13

Posted 24 March 2014 - 05:08 PM

View Postschmunk, on 24 March 2014 - 12:36 PM, said:

This is due to a Yii 2 API change, see here for how to update the app config:
https://github.com/p...ig/web.php#L100

Corresponding guide section: http://stuff.cebe.cc...ults-class-wide


Thanks a lot!
0

#11 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 12 January 2015 - 10:59 PM

Also listed here now.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#12 User is offline   Kavitama 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 20-September 11
  • Location:Argentina - C.A.B.A.

Posted 25 April 2015 - 11:27 PM

Sorry for bothering but I think I didn't understand how to use providers

I'd like to have the Relation one applied to allow me to select value (dropdonw and not) coming for a related table.

HOw I do it?



Sometimes your whole life boils down to one insane move !
0

#13 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 27 April 2015 - 02:17 AM

If you want to change the displayed value in the dropdown, you can add a getLabel() function to your model an regenerate the CRUDs. See https://github.com/s...erator.php#L143
We need to make this functionality more customizable, I think.

Another option would be to to create a custom provider for the related field, eg. to additionally set htmlOptions.
see https://github.com/s...allbackprovider
In your case, adjust the key (common\models\Foo.isAvailable) to match your model attribute, get the related data you want and replace checkbox with dropdown.


Does this help?
Do you use the giiant-batch command by the way?

Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#14 User is offline   Kavitama 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 20-September 11
  • Location:Argentina - C.A.B.A.

Posted 01 May 2015 - 06:41 PM

View Postschmunk, on 27 April 2015 - 02:17 AM, said:

If you want to change the displayed value in the dropdown, you can add a getLabel() function to your model an regenerate the CRUDs. See https://github.com/s...erator.php#L143
We need to make this functionality more customizable, I think.

Another option would be to to create a custom provider for the related field, eg. to additionally set htmlOptions.
see https://github.com/s...allbackprovider
In your case, adjust the key (common\models\Foo.isAvailable) to match your model attribute, get the related data you want and replace checkbox with dropdown.


Does this help?
Do you use the giiant-batch command by the way?



Hi schmunk,
I am getting mad ad I am not sure if it si because I'm not getting the real differences between YII 1.1 and YII 2.0 or because I converted myself into a dumb!!!
Anyway, I am not using the batch for the moment, I am still trying to evaluate which "advanced GII" I'd like to use as my toolset.
I am used to YII 1.1.16 and Awecrud with some changes I made to have it just as I like it and one of the things "included" were the realtion things out of the box.
So my main job had to be done at DB level and as a conseuquence to the model level where eventually i could change something to make it more compliant.
SO if I were defining that the representing column of a realted table was for istance a date instead of a description i could get that data automatically into any related table reference (description into the grid, dropdowns in a form etc).

Am I starting from the right place if I'd like to have the same using your extension?

Again thank you in advance for any light you can shed on this!
Kavi
Sometimes your whole life boils down to one insane move !
0

#15 User is offline   Kavitama 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 20-September 11
  • Location:Argentina - C.A.B.A.

Posted 02 May 2015 - 05:05 PM

View PostKavitama, on 01 May 2015 - 06:41 PM, said:

Hi schmunk,
I am getting mad ad I am not sure if it si because I'm not getting the real differences between YII 1.1 and YII 2.0 or because I converted myself into a dumb!!!
Anyway, I am not using the batch for the moment, I am still trying to evaluate which "advanced GII" I'd like to use as my toolset.
I am used to YII 1.1.16 and Awecrud with some changes I made to have it just as I like it and one of the things "included" were the realtion things out of the box.
So my main job had to be done at DB level and as a conseuquence to the model level where eventually i could change something to make it more compliant.
SO if I were defining that the representing column of a realted table was for istance a date instead of a description i could get that data automatically into any related table reference (description into the grid, dropdowns in a form etc).

Am I starting from the right place if I'd like to have the same using your extension?

Again thank you in advance for any light you can shed on this!
Kavi


Hi again,

I think I need to clarify my previous comment and also my expectations so, maybe, my asking would appear clearer...

Since the idea behind giiant is to "restore" some of the good things coming from giix and awecrud, I was expecting to see mostly the same things in a more elegant YII2 styled script.
And I can see this in the way you Schmunk did it, no doubt but...
... I am missing some features that hopefully are already in but I am not able to grasp (not sure if it is due to YII2 changes or because I dont understand them)!

An admin.php (now index.php) out of the box with "awecrud":
<?php 
	$this->widget('bootstrap.widgets.TbExtendedGridView',
		array(
			//'fixedHeader' => true,
			//'headerOffset' => 40,
			'responsiveTable' => true,
			'template' => "{pager}\n{summary}\n{items}\n{pager}",
			'id' => 'one-subsidiary-user-grid',
			'type' => 'striped bordered condensed',
			'dataProvider' => $model->search(),
			'filter' => $model,
			'columns' => array(
				array(
                    'name' => 'subsidiary_id',
                    'value' => 'isset($data->subsidiary) ? $data->subsidiary : null',
                    'filter' => CHtml::listData(OneSubsidiary::model()->findAll(), 'id', OneSubsidiary::representingColumn()),
                ),
				array(
                    'name' => 'user_id',
                    'value' => 'isset($data->user) ? $data->user : null',
                    'filter' => CHtml::listData(ModUser::model()->findAll(), 'id', ModUser::representingColumn()),
                ),
				array(
					'name' => 'is_default',
					'value' => '($data->is_default == 0) ? Yii::t(\'AweCrud.app\', \'No\') : Yii::t(\'AweCrud.app\', \'Yes\')',
					'filter' => array('0' => Yii::t('AweCrud.app', 'No'), '1' => Yii::t('AweCrud.app', 'Yes')),
					),
				array(
					'class'=>'bootstrap.widgets.TbButtonColumn',
					'header' => Yii::t('AweCrud.app', 'Operations'),
				),
			),
		)
	); 
?>


A _form.php out of the box with "awecrud":
<div class="form">
	<?php
		/** @var OneSubsidiaryUserController $this */
		/** @var OneSubsidiaryUser $model */
		/** @var AweActiveForm $form */
		$form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
			'id' => 'one-subsidiary-user-form',
			'enableAjaxValidation' => true,
			'enableClientValidation'=> true,
		)); 
	?>

	<p class="note">
		<?php echo Yii::t('AweCrud.app', 'Fields with') ?> <span class="required">*</span>
		<?php echo Yii::t('AweCrud.app', 'are required') ?>.
	</p>

	<?php echo $form->errorSummary($model) ?>

	<?php echo $form->dropDownListRow($model, 'subsidiary_id', array(''=>Yii::t('app','ddSelect')) + CHtml::listData(OneSubsidiary::model()->findAll(), 'id', OneSubsidiary::representingColumn())) ?>
	<?php echo $form->dropDownListRow($model, 'user_id', array(''=>Yii::t('app','ddSelect')) + CHtml::listData(ModUser::model()->findAll(), 'id', ModUser::representingColumn())) ?>
	<?php echo $form->checkBoxRow($model, 'is_default') ?>

	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>$model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
		)); ?>
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'label'=> Yii::t('AweCrud.app', 'Cancel'),
			'htmlOptions' => array('onclick' => 'javascript:history.go(-1)')
		)); ?>
	</div>

	<?php $this->endWidget(); ?>
</div>


The main issue solved by the "awecrud" extension in YII 1.1 was getting the related table data right associated to the column of the model whose "index view" was built on and generate the dropdowns for the table's foreign keys like I am putting in evidence extracting them form the above code:
array(
	'name' => 'subsidiary_id',
	'value' => 'isset($data->subsidiary) ? $data->subsidiary : null',
	'filter' => CHtml::listData(OneSubsidiary::model()->findAll(), 'id', OneSubsidiary::representingColumn()),
),

and

<?php echo $form->dropDownListRow($model, 'subsidiary_id', array(''=>Yii::t('app','ddSelect')) + CHtml::listData(OneSubsidiary::model()->findAll(), 'id', OneSubsidiary::representingColumn())) ?>


Can I get something like this "out of the box" with GIIANT? If yes can you help me in doing it?

Again thank you in advance for any light you can shed on this.

Regards
Kavi
Sometimes your whole life boils down to one insane move !
0

#16 User is offline   dustbin1_uk 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 70
  • Joined: 03-February 15

Posted 03 May 2015 - 03:49 PM

Am I right in thinking this is included in the package here: http://phundament.com/
0

#17 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 04 May 2015 - 03:14 AM

@dustbin1_uk Yes, giiant is included in Phundament. We're doing some final restructuring at the moment to get ready for 4.0.0-rc1

@Kavitama it's not as out of the box as it was in Yii1 with gtc or awecrud ...

The basic idea would be either to define a callback in the universal CallbackProvider or to add this to the Relation provider.

This is an example for a column with a filter (dropdown) for a related "Gallery"model.


    $columnAtttributes = [
        'app\models\Gallery'             => '[
            "class" => yii\\grid\\DataColumn::className(),
            "attribute" => "gallery_id",
            "value" => function($model){
                $rel = $model->getGallery()->one();
                return yii\helpers\Html::a($rel->title,["/crud/gallery/view","id" => $rel->id]);
            },
            "format" => "raw",
            "filter" => yii\helpers\ArrayHelper::map(
                app\models\Gallery::find()->all(),\'id\',\'title\'
            )
        ]',



See here for the usage: https://github.com/s...allbackprovider


I still need to find a way to add this feature in a safe way by default.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#18 User is offline   Kavitama 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 20-September 11
  • Location:Argentina - C.A.B.A.

Posted 04 May 2015 - 03:13 PM

View Postschmunk, on 04 May 2015 - 03:14 AM, said:

@dustbin1_uk Yes, giiant is included in Phundament. We're doing some final restructuring at the moment to get ready for 4.0.0-rc1

@Kavitama it's not as out of the box as it was in Yii1 with gtc or awecrud ...

The basic idea would be either to define a callback in the universal CallbackProvider or to add this to the Relation provider.

This is an example for a column with a filter (dropdown) for a related "Gallery" model.

See here for the usage: https://github.com/s...allbackprovider

I still need to find a way to add this feature in a safe way by default.


Fair enough!
I will dive into the callbackprovider and have enough time to wait for a "safe schmunk solution" :-)
Is it correct if I say the new structure in YII2 is complicating this way of delivering applications??
Sometimes your whole life boils down to one insane move !
0

#19 User is offline   schmunk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 580
  • Joined: 02-November 08
  • Location:Stuttgart, Germany

Posted 06 May 2015 - 09:38 AM

> Is it correct if I say the new structure in YII2 is complicating this way of delivering applications??


Depends on your app structure :)
We developed Phundament as an application template with focus on Docker from development to deployment.
With this, our deployments are running very smooth now, we're working on 4.0.0-RC1 of Phundament btw.
Phundament - Yii Application Boilerplate with composer support
Fork on github

Follow phundament on Twitter

DevSystem: Mac OS X 10.7 - PHP 5.3 - Apache2 - Yii 1.1 / trunk - Firefox or Safari
0

#20 User is offline   Kavitama 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 20-September 11
  • Location:Argentina - C.A.B.A.

Posted 06 May 2015 - 01:32 PM

View Postschmunk, on 06 May 2015 - 09:38 AM, said:

> Is it correct if I say the new structure in YII2 is complicating this way of delivering applications??

Depends on your app structure :)
We developed Phundament as an application template with focus on Docker from development to deployment.
With this, our deployments are running very smooth now, we're working on 4.0.0-RC1 of Phundament btw.


I have been looking at Phundament lately and I like the idea behind that but I really need to solve that "piece of cake" I was showing.
My developments are mainly based on complex DB structures in which I find myself very attuned and then generate the app, that is why I was so unhappy to see those YII2 changes in the structure of doing things.
I have the doubt this is affecting a lot the way YII2 is really competing with other frameworks but this is off topic and only my personal opinion!
Sometimes your whole life boils down to one insane move !
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users