A powerful component of Drupal is the Module system which is the strength of Drupal as an open source web development ecosystem. Because of the clever design of the "hook" system, it is easy for developers to provide functionality and features that work smoothly with the core and other modules if the developers follow the published APIs.

As Drupal getting bigger, for every major version of Drupal core, the task of updating modules becomes exponentially bigger and more complex because of the drastic changes in core APIs and the interconnections among core and contributed modules. Both developers and end users demand simpler and quicker solutions, otherwise the lag between newly released core and full productions will become so big that users (and module developers) won't have the energy and patience to catch up with the core at all.

A solution I propose here is based on the ideas of declarative programming and code generation.

Drupal already has two powerful systems to generate SQL and XTHML. They are proved to be effective and productive in building complicated interactive systems.

If we follow the same patterns in database and theme systems to design code generation layers for modules that not only validate but automatically generate code according to the new APIs, it would save a lot of time in module migration and maintenance. The implementation can be done in the fashion of theme engines or XSLT.

The code generation layers could work in three stages:

  • Convert existing modules into template + meta data
  • Code review and debug on template and meta data
  • Assemble module code in install profile, features, pluggin manager, etc.

The last stage can be configured (again with meta data) for development, testing, and production separately and live in separate version control system.

This approach might solve many problems raised in http://groups.drupal.org/node/24709.

I am not familiar enough with Drupal system to actually implement this but I think many people in the community can. If it is too late before the D7 code freeze, then we could do it in Drupal 8.

Comments

SLIU’s picture

Issue tags: +code generation

A quick search on code generation and module builder shows following links:

http://drupal.org/node/363891
http://drupal.org/node/345118
http://drupal.org/node/340723

http://drupal.org/project/module_builder
http://drupal.org/project/builder

For some reason the last one never took off.

Unlike the links above that mostly address performance and user experience issues, this feature request is about module development, depolyment and maintenance using templates and meta data.

Josh Waihi’s picture

Actually generating PHP on the fly is really dangerous. I'm no that confident Drupal core could actually do this just yet. I would have to say this idea would have to be able to fly as a contrib module first before merging into Drupal. Also PHP 5.3 or PHP 6 could be better to implement this with, with features like namespaces, it could solve scope issues if hooks were compiled together.

I actually think tools like drush (http://drupal.org/project/drush) would be best fitted for this feature. It can look at existing modules and if I merge my stuff from http://geek.joshwaihi.com/content/commandline-tool-drupal-module-develop... it could be come quite possible a means for upgrading modules - nevertheless a module generator.

Would like to get catch and Crell's opinion on this one.

SLIU’s picture

I don't mean generating PHP on the fly but at the install/update stage with install profile, plugin manager and features.

I agree template engines should be implemented in a separate file system using tools like drush, but this request is for core API because only core can define and coordinate meta data about modules. With well defined structured meta data (more complex than the flat .info files) about the functionality and dependancy, modules can provide/consume more structured information so that they can be managed and maintained more efficiently.

sun.core’s picture

Version: 7.x-dev » 8.x-dev
jhedstrom’s picture

Status: Active » Closed (won't fix)

Given the monumental overhaul in 8.0.x, I don't think it would be possible to pursue this. As mentioned in #2, scaffolding can be done with either drush or drupal console.