PHP Classes


Recommend this page to a friend!
  Classes of Alexander Selifonov   waPluginator   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: waPluginator
Generate sets of source files from templates
Author: By
Last change: Update of
Date: 1 year ago
Size: 2,465 bytes


Class file image Download

Code generator for modules, plugins and landing pages

Majority of web applications, CMS systems, frameworks use "modular" (or plugin) architecture. It allows easy developing of new functionality and adding it to the system independently from other modules. Quite often modules, or plugins, have a similar structure, so it would be great to have a kind of "template" with places for inserting specific "variable" values, and then create "initial stub" for a new module with these values inside. After that developer can modify generated files, adding needed specific (function implementation, CSS styling etc.)

Another often task is creating a collection of files for a "single page" - for example, adaptive landing page, based on predefined design.

For example, you want to create a landing page based on some royalty free pages available in internet, but you don't want each time to search places where to insert your titles, text blocks, css color codes etc.

In that case you just modify source page files, by adding special macros (like %textblock01%), and describe them in waPluginator config file.

waPluginator renders an html "designer" form for choosing template, entering user values and executing the "module creation process".

Using example

// waPluginator::setBaseUri('./backend.php'); // Use it if you have your own backend module
        'appname' =>'Your application name'
       ,'author' =>'My Name'
       ,'email' =>'Myemail [at]'
       ,'link' =>''
$params = array_merge($_GET,$_POST);
if(!empty($params['action'])) {
else {
    app::setPageTitle('Plugin generator');

waPluginator uses CodePreprocessor to parse template files, but it allows attaching any additional text/source code processors (compilers), like "scss to css", "less to css" etc. You can attach compiler if it is implemented as PHP class with callable "compiling" method.

Working demo can be found in demo folder - generator.php

See using details in wiki