是否存在PHP生成器框架或引用?

时间:2022-09-25 23:25:36

Back in the scripted ASP and ColdFusion days, I used to work on projects that would build code generators for ASP or Coldfusion, typically in C++, in order to be more object oriented in application design and not have developers writing scripted code, which often was called "spaghetti code" for it's size and complexity.

回到脚本化的ASP和ColdFusion时代,我曾经处理过为ASP或Coldfusion构建代码生成器的项目,通常是在C ++中,以便在应用程序设计中更加面向对象,而不是开发人员编写脚本代码,这通常是因其大小和复杂性而被称为“意大利面条代码”。

Since I've been coding asp.net since 2000, I haven't really had to deal with the issue at all, since the platform is not scripted.

自从我从2000年开始编写asp.net以来,我根本没有必要处理这个问题,因为该平台没有编写脚本。

I may be working on PHP projects in the future, and I was wondering if any code generators for PHP exist, or if any good references for building these generators exist. It would be for the Linux platform, not targeted to Win2008 Servers running PHP.

我将来可能正在研究PHP项目,我想知道是否存在任何PHP代码生成器,或者是否存在构建这些生成器的任何好的参考。它将用于Linux平台,而不是针对运行PHP的Win2008服务器。

3 个解决方案

#1


1  

I'm rather sceptical on the merits of code generation in the context of a dynamic language, such as PHP. You can generally use other kinds of abstraction to get the same results. Unlike a statically typed, compiled language, it is rather easy to use dynamic hooks such as __get and __set and reflection, to make generic abstract objects.

在动态语言(如PHP)的上下文中,我对代码生成的优点持怀疑态度。您通常可以使用其他类型的抽象来获得相同的结果。与静态类型的编译语言不同,使用动态钩子(如__get和__set和反射)来制作通用抽象对象相当容易。

#2


2  

Why not just build a proper app in PHP instead of going through the hassle? Recent PHP is fully object-oriented and lets you do some pretty decent stuff. There are even frameworks that help you do this kind of stuff.

为什么不在PHP中构建一个合适的应用程序而不是经历麻烦?最近的PHP完全面向对象,让你做一些相当不错的东西。甚至有框架可以帮助你做这种事情。

#3


1  

It's better that you learned good development practices in PHP than use code-generators. PHP might be a scripting language but it is quite potent, has a nice OO model, plenty of good frameworks and other open-source packages.

在PHP中学习良好的开发实践比使用代码生成器更好。 PHP可能是一种脚本语言,但它非常有效,有一个很好的OO模型,很多好的框架和其他开源软件包。

It's up to the developer to create well designed and factored code base, regardless of whether it's compiled at run-time or not.

开发人员可以创建设计良好且考虑周全的代码库,无论它是否在运行时编译。

#1


1  

I'm rather sceptical on the merits of code generation in the context of a dynamic language, such as PHP. You can generally use other kinds of abstraction to get the same results. Unlike a statically typed, compiled language, it is rather easy to use dynamic hooks such as __get and __set and reflection, to make generic abstract objects.

在动态语言(如PHP)的上下文中,我对代码生成的优点持怀疑态度。您通常可以使用其他类型的抽象来获得相同的结果。与静态类型的编译语言不同,使用动态钩子(如__get和__set和反射)来制作通用抽象对象相当容易。

#2


2  

Why not just build a proper app in PHP instead of going through the hassle? Recent PHP is fully object-oriented and lets you do some pretty decent stuff. There are even frameworks that help you do this kind of stuff.

为什么不在PHP中构建一个合适的应用程序而不是经历麻烦?最近的PHP完全面向对象,让你做一些相当不错的东西。甚至有框架可以帮助你做这种事情。

#3


1  

It's better that you learned good development practices in PHP than use code-generators. PHP might be a scripting language but it is quite potent, has a nice OO model, plenty of good frameworks and other open-source packages.

在PHP中学习良好的开发实践比使用代码生成器更好。 PHP可能是一种脚本语言,但它非常有效,有一个很好的OO模型,很多好的框架和其他开源软件包。

It's up to the developer to create well designed and factored code base, regardless of whether it's compiled at run-time or not.

开发人员可以创建设计良好且考虑周全的代码库,无论它是否在运行时编译。