-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first draft of the extension generator #2411
first draft of the extension generator #2411
Conversation
Nope, based on our previous discussion.
We probably don't need this input field. This generator should only be used to generate extensions. Besides extensions, users may also want to generate application templates, which should be handled by a different generator, IMO.
Make it simple. Just use comma as the separator. No brackets. User can always fine tune the composer file.
Again, keep it simple. No auto generation (how would you generate it from, anyway?)
No.
Under
I don't understand ... |
But I'd then set The type field is very crucial IMO, because this is the one field you really can use for filtering, tags and name is pretty much useless. Will modify the keyword section. Autogenerating (it's merely a type hint) the namespace should just help the user to get familiar with namespaces. You can still change that if you want to. Sorry, but in I meant the explanation have you've generated an extension, I'll add some screens... |
I'm wondering if we really need this generator (sorry...) Gii is designed to generate code to be part of the application it is running in. Based on the discussion and your screenshot, it seems all this generator does is mainly to fill in the It perhaps is more convenient that we provide a template and users copy it to the place they want and modify it directly. As long as |
The main advantage of the generator is, that it guides the user through the process of creating an extension. It is similar to Forking an skeleton-extension is also not perfect, because every extension will be a fork of the skeleton, very confusing, IMHO. And to be honest, one of the biggest problems in Yii1 was, that there were almost no guidelines for creating extensions, which made it very hard to use them in combination sometimes, because every developer did it in another way - just because of missing guidelines. I saw so many weird ideas for Yii2 extensions already, eg. using Yii itself is so straight and clean. The next generation of extensions should follow its example. PS: I don't think it makes sense to create an application with Gii. But Gii itself does not have to be limited to generating application related code. |
Ok, I'm fine with either approaches. Let's see how other people feel about this PR. |
👍 even as I would prefer a "forkable" repository, as I normaly would like to manage the extensions "outside" a complete project... I have them all seperated, as most of them are really reusable code snipets independent of the current project im working on... |
👍 😄 Maybe our workflows are different, but since composer I am always developing extensions (or yii2-dev) directly in What do you mean with "manage outside a complete project"? The generator just generates temporary code which has to be pushed to a repo, but this is the same workflow, like you'd do it manually. |
well, for me it's really more easy to develop and take care of the extension outside the project, as I normaly use my widgets in multiple smaller sites... so I try to keep application related "extensions" as modules... but thats just my own opinion... :) anyway i like the result as template, that I can then move outside to a "new" folder;) |
Hey Guys, I often used schmunk42/gii-template-collection for yii(1) as codegenerator and still find it very useful! Would be nice to have this extension in yii2 :) |
I think it's very useful for motivating people to create and share extensions. |
Not sure about this one, it only holds some things like creating |
The API does not support that, AFAIK. |
maybe then pospone this one until it will be? it would be great though. Can you create in composer repo issue? |
right, so as i see it will not be done in nearest future? ok then. |
I also think that an extension generator would be a great addition. Having developed quite a few extensions myself I must say that it would had been very useful to have a generator like this when I started with my first extension. There are quite a few good practices when it comes to developing extensions that many do not know about, especially those new to Yii. As a side node; I also tend to develop my extensions under vendor now a days because I constantly keep improving my them during the development of larger projects. |
@schmunk42 great addition to gii is exactly the help what I'm looking for. |
Updated. Please let me know, if there are still open issues. |
Keywords don't save between preview and generate commands. Have some enhancement issues:
|
I think it's ready to be merged. All the future enhancements could be done by separate pull requests. @qiangxue is neutral about taking it. I want more opinions. @mdomba, @resurtm, @tonydspaniard, @cebe, @klimov-paul, @creocoder. |
#if (Yii::$app->hasModule($this->moduleID)) { | ||
# $link = Html::a('try it now', Yii::$app->getUrlManager()->createUrl($this->moduleID), ['target' => '_blank']); | ||
# return "The module has been generated successfully. You may $link."; | ||
#} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this? #
comments and a link to a module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, will remove this.
$output1 = <<<EOD | ||
<p><em>The extension has been generated successfully.</em></p> | ||
<p>To enable it in your application, you need to create a git repository | ||
and require via composer.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and require it via composer.
looks good to me, the comment as noted above should be removed. |
|
||
/** | ||
* This generator will generate the skeleton files needed by an extension. | ||
* @property tbd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can leave it here, will be automatically removed by phpdoc tool.
@index0h Thanks! I added a keywords safe validator. |
first draft of the extension generator
Merged. @schmunk42 please create a separate issue for enhancements. |
Description
Enter the desired values to create a Yii2 extension ready for usage with composer.
There are currently three files generated: composer.json, README.md and AutoloadExample.php.
This is not final yet. I need some input.
Questions
Q: Should we enforce the
yii2-
prefix for the package name?I'd say yes. Will keep a consistent naming across extensions. Can still be changed manually.
How can I prepend yii-2 in the input field or render a form field without label?
Q: Which values should be available for
type
, do we need more?Q: How to handle the array input for keywords?
We could add the most popular tags from Yii1.
I'd like to do this input with a Select2 widget, but is it available already (in the core).
Q: What do you think about autogenerating the namespace, is the JavaScript implementation sufficient?
Q: Should title also be autogenerated?
ucFirst(packageName)
Q: Where should the extension be generated?
Q: What do you think about the testing explanation.
Validation and Prefix and Namespace rendering have to be improved, but I wanted to clear the above points first.