PHP code example of strukt / generator
1. Go to this page and download the library: Download strukt/generator 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/ */
strukt / generator example snippets
$data = array(
"title" => "The Title",
"subtitle" => "Subtitle",
"footer" => "Foot",
"people" => array(
array("name" => "Steve","surname" => "Johnson"),
array("name" => "James", "surname" => "Johnson"),
array("name" => "Josh", "surname" => "Smith")
),
"page" => "Home"
);
$tpl = "<html>
<title>{{title}}</title>
<body>
<h1>{{subtitle}}</h1>
{{begin:people}}
<b>{{name}}</b> {{surname}}<br />
{{end:people}}
<br /><br />
<i>{{footer}}</i>
</body>
</html>";
$output = Strukt\Templator::create($tpl, $data);
/**
* @Route(/)
*/
class DefaultController{
/**
* @Route(/hello/{to:alpha})
* @Method(POST, GET)
* @Provides(application/html)
*/
function hello($to){ ...
/**
* @Route(/login)
* @Method(GET)
* @Secure(username=test, password=test)
* @Expects(username,password)
*
* note the below will not be parsed
* @param str $username
* @param str $password
*/
function login($username, $password){ ...
$parser = new \Strukt\Annotation\Parser\Basic(new \ReflectionClass("\Controller\DefaultController"));
print_r($parser->getAnnotations());