After writing Fork modules on a daily base for over half a year and thinking about improving this process a lot, I got the idea to write a module that generates other modules. I already used the Knife CLI tool made by Jelmer Snoeck and a lot of snippets but I still felt I wrote the same code way to often. This newly created module is used to filter away monkey jobs (like creating forms in the backend) and to give us, developers, more time to optimize and test our code.
What can you do with it?
The module generates a fully installable module with a good working backend and a basic frontend. It uses a wizard to let you choose
- which fields you want to use in your items
- which field to hook the meta on
- if you want to use drag and drop sequencing
- if you want to make some fields searchable
- if you want to use categories
- if you want to add tags
- if you want a multifileuploader to add multiple images to each item
In the frontend, the generated code contains some best practices like meta tags, open graph tags and Twitter card.
Caution! This is made to generate basic structures of modules, they are not fully optimized . Don't forget to check the code and test every action. If you encounter problems or see possible improvements, you can report bugs in the GitHub issues or do a pull request.
How do you use it?
Step 1: information
In the first step, you can add information about your module. This will be used in the info.xml file and in the PHPDoc blocks above the generated classes.
Step 2: fields
In the second step, you can add a lot of types of fields. All most used field types are present and some have extra options. You can choose if your chosen fields are required and add a default value.
Step 3: Special fields
In step 3, you can add extras. These include choosing a meta field, search fields, using tags, sequencing categories and an awesome multi image upload.
Step 4: Blocks
Step 4 is used to change some properties that will be used in the generated frontend. For the time being, you can only choose to use twitter cards on a detail page and specify the wanted twitter name.
That's it! We're ready to generate our module. After clicking 'generate', all needed code is put together and we're asked if we want to install our new module.
How does it work?
The module maker uses base templates and fills it up with customized snippets for each field/property. It uses a replacement technique that resembles the template engine in Fork. If you want to dive into the code you can find it on GitHub.
This module is partially made inside Wijs and will be maintained by its employees. It will be held up to date with the upcoming releases of Fork and new features will be added soon. Best practices that are used in the company will be integrated in the module to make more standardized and high quality modules.
When Fork will contain more Symfony components, a lot if this module generator will be replaceable by the app console and Doctrine ORM. If it still seems this module will save us a lot of time, it will also be maintained for this upcoming version of Fork too.