用于创建类模板的 NetBeans 插件
我正在寻找 NetBeans PHP 的插件(或者它可以是一些外部工具),它可以执行类似的操作:
- 运行时,它会询问该类的类名和私有属性(及其类型)的名称
- 然后它会生成以下内容类:
- 所有列出的具有 vdoc 格式类型的属性,
- 构造函数,将所有属性作为参数并使用这些值初始化类属性,
- 默认的 getter 和 setter。
我知道编写这样的工具并不难,但也许它已经存在了。
I am looking for plugin for NetBeans PHP (or it can be some external tool) that would do something like that:
- When run it asks for a class name and the names of private attributes (and their types) of this class
- Then it generates this class with:
- all listed attributes with types in vdoc format,
- constructor that takes all the attributes as parameters and initialize class attributes with those values,
- default getters and setters.
I know it's not difficult to write such tool, but maybe it already exists.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Netbeans 已经具有一些与此类似的内置功能。在任何 PHP 项目中,创建一个新的 PHP 类(右键单击项目中的文件夹,新建 -> PHP 类)。输入您的属性,例如:
Alt +Insert 将弹出一个菜单,允许您生成构造函数、getter 和 setter 来为属性赋值。
如果您想要执行更多操作,可以查看这篇有关代码生成的 Netbeans 文章。
Netbeans has some built-in functionality similar to this already. In any PHP project, create a new PHP Class (right click a folder in the project, New -> PHP Class). Enter your properties, such as:
Alt+Insert will bring up a menu that allows you to generate a constructor, getters, and setters to assign values to your properties.
If you want to do more, you can look at this Netbeans article on code generation.
NetBEans 没有这样的插件(AFAIK),但无论如何它都不是它的工作。此类类可以从 YAML/XML/数据库模式元数据自动创建。 ORM 通常有相应的工具,但创建自己的工具也不难。
There's not such plugin for NetBEans (AFAIK), but it's not the job for it anyway. Such classes can be created automatically from YAML/XML/database schema meta data. ORMs usually have tools for that, but creating your own should not be difficult either.