Create Modules with Tina4
Develop your system as a normal Tina4 project, when you're done developing it, change your index to have the following code.
<?php
\Tina4\Module::addModule("My Module", "1.0.0", "tina4cms", function(\Tina4\Config $config) {
global $DBA; //access the database
//All your things that need to run when you start
if (!$DBA->tableExists("someTable")) {
(new \Tina4\Migration(__DIR__."/migrations"))->doMigration();
}
//Add a twig function as Example
$config->addTwigFunction("render", function ($content) {
return \Tina4\renderTemplate($content);
});
});
Your module can now be included in any other Tina4 project that you would like to create. Tina4 is designed to make things as lightweight as possible. If you have any queries or suggestions please feel free to reach out to our Developers.