Code generators
#1
Posted 07 August 2011 - 11:57 AM
Problems
- Maintaining templates for these two methods is double amount of work.
- Command line code generation is deprecated but is still used by developers.
Solution
- Same templates for both cli and Gii.
- API to use these templates.
- Gii and cli using API.
#2
Posted 07 August 2011 - 08:27 PM
What do you mean by "Still, in some cases it's preferred to use command line."?
I mean, isn't it enough just to remove those yiic commands that have their equivalents in Gii?
This post has been edited by softark: 07 August 2011 - 10:04 PM
#3
Posted 08 August 2011 - 07:01 AM
1. Some developers are preferring CLI instead of UI.
2. If you want to re-generate models automatically, for example, at SVN/Git commit hook you'll need either CLI or API.
#4
Posted 08 August 2011 - 08:11 AM
If there was a way to bring the two together so that they can share templates it would be wonderful.
Sr. Developer at Envisage International
D.H. Luther - Web Design & Development
Dana's Yii Blog
Extensions:
ChildrenRequiredValidator | ESitemap | EStrongPassword | ES3
#5
Posted 08 August 2011 - 08:25 AM
What about the modifications and/or additions that a developer has made to his customized Gii? Could they still be applicable to CLI?
Templates may be OK, but what if he has modified the UI and added some extra fields to it?
#6
Posted 08 August 2011 - 08:26 AM
#7
Posted 16 August 2011 - 12:23 PM
for now it's just showing diff, but with cli you won't get this conveniently
it worth to concentrate on gii and improve the generators
#8
Posted 16 August 2011 - 05:25 PM
#10
Posted 19 August 2011 - 06:58 AM
I was very disappointed when first saw "yiic" is deprecated.
I think nobody will argue that most of php developers use console anyway (for server maintenance etc).
As for me, console is more convenient, it's faster to type than to click and type, and is easier to extend (I'm using yiic shell for running my own commands for technical maintenance of php service - dropping cache, and so on).
Also, yiic is zero-configuration and doesn't need to be disabled after deployment.
My vote is for yiic
#11
Posted 19 August 2011 - 08:35 AM
we should differentiate this...
Yiic is still used for creating a new webapp and for various CLI commands...
In the beginning yiic was used to create models and CRUD, too... and that is the part that was deprecated in favor of the more flexible Gii...
So we are talking here only for this part if yiic or did I understood this wrong?
As for me - for the code generation I use Gii... and IMO we can remove the model and crud from yiic... no need to have it doubled as there is no way to offer or possibilities of Gii in yiic...
#12
Posted 19 August 2011 - 08:36 AM
when develop application we should support both GUI and CLI interfaces to end client . GUI is for human beings, CLI is for program , these two interfaces should share the logic and data access layers. so the solutions samdark give is well. they can use api which is a intermediate layer to share the templates thus to reduce maintenance costs .
#13
Posted 19 August 2011 - 11:15 AM
Would be nice if they could be made to make use of the same templates/code/whatever.
One thing that I'd like to have is a web-based interface to the migrate shell.
Sometimes you don't have shell access on a host.
A web based interface with diff view would be really neat.
#14
Posted 19 August 2011 - 12:20 PM
Yes, we're discussing code generation only.
jacmoe
Check my webshell extension.
#15
Posted 19 August 2011 - 01:16 PM
my initial flow is the following:
- yiic webapp
- yiic migrate create install
- edit database settings in config/main.php, config/console.php
- yiic migrate
- yiic shell for creating modules, models and cruds
this is really saving me a lot of time
#16
Posted 22 August 2011 - 06:01 AM
Console is just way more convenient.
#17
Posted 23 August 2011 - 06:16 AM
#18
Posted 23 August 2011 - 01:21 PM
CakePHP model/view/crud generation by the command-line is really awful..
No preview either..
I also like Giix instead of Gii.
#19
Posted 25 August 2011 - 07:20 AM
The WEB part is great, especially the ability to preview what is actually generated and select the files you want (sometimes I need 1 or 2 files from CRUD generator, not all of them).
And what I really want, is ability to use some DB specific features like checking the box "Use MySQL specific features" witch will understand "ENUM" type fields and actually generate a rule like
array('field', 'in', 'range' => array('ENUM1', 'ENUM2, ..., 'ENUMN')
or date type fields.
That should be build-in from the start, but optional. Need one? Tick the checkbox (and maybe be able to define defaults in config).
I had a discussion with SamDark about adding DB specific code generating to Gii and the reasoning for not doing it is solid - we provide cross-db functionality. Totally understand the reason. But the reality is - how many people really write cross-db code? Some, yes. But not majority. So I think there has to be db specific code generation in Gii - just optional, not enabled by default (unless done in config). People will use it, and they will be happy for sure. And I'm 100% sure community will fill in the gaps with patches quite fast for every supported DB.
#20
Posted 25 August 2011 - 10:33 AM
samdark, on 19 August 2011 - 12:20 PM, said:
Check my webshell extension.
You are right.
And I did.
It's actually pretty simple, also without using the webshell extension:
private function runMigrationTool() {
$commandPath = Yii::app()->getBasePath() . DIRECTORY_SEPARATOR . 'commands';
$runner = new CConsoleCommandRunner();
$runner->addCommands($commandPath);
$commandPath = Yii::getFrameworkPath() . DIRECTORY_SEPARATOR . 'cli' . DIRECTORY_SEPARATOR . 'commands';
$runner->addCommands($commandPath);
$args = array('command', 'yiic', 'migrate', '--interactive=0');
$command = $runner->createCommand($args[0]);
array_shift($args);
ob_start();
$runner->run($args);
echo htmlentities(ob_get_clean(), null, Yii::app()->charset);
}
The only problem is that web app doesn't do command map.
Which is needed for the migrate script if I want to use a custom migration class and/or use a table prefix for the migration table.
If a web application could have a command map, I'd be happy.

Help

This topic is locked













