1. Go to this page and download the library: Download jelix/castor 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/ */
jelix / castor example snippets
// directory where compiled templates are stored
$cachePath = realpath(__DIR__.'/temp/') . '/';
// directory where templates can be found
$templatePath = __DIR__.'/';
// create a configuration object. See its definition to learn about all of its options
$config = new \Jelix\Castor\Config($cachePath, $templatePath);
// let's create a template engine
$tpl = new \Jelix\Castor\Castor($config);
// assign some values, so they will be available for the template
$users = array(
// User in an example class...
new User('Tom', '2001-02-01'),
new User('Laurent', '1990-03-01'),
new User('Bob', '1970-05-25')
);
$tpl->assign('users', $users);
$tpl->assign('titre', 'This is a test !');
// content is generated from the given template file and returned
$content = $tpl->fetch('test.tpl');
// or content is generated from the given template file and sent directly to the browser
$tpl->display('test.tpl');