1. Go to this page and download the library: Download twigwp/twig-wordpress library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
twigwp / twig-wordpress example snippets
class MyModule implements TwigWp\Module\Injectable {
public function injectInto(\Twig\Environment $twig): \Twig\Environment {
// Do your stuffs here.
return $twig;
}
}
$provider = new Provider(new \Twig\Environmnet());
add_filter('twigwp.modules', function($modules)
{
$modules['module_name'] = new MyModule();
return $modules;
});
$modules = $provider->modules();