PHP code example of techart / frontend-api

1. Go to this page and download the library: Download techart/frontend-api 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/ */

    

techart / frontend-api example snippets



$env = new Techart\Frontend\Environment(new EnvEnvironmentStorage());
$pathResolver = new \Techart\Frontend\PathResolver('../frontend', ['twigCachePath' => '../twig']);

$frontend = new \Techart\Frontend\Frontend($env, $pathResolver);


$frontend->assets()->cssUrl('index');

$frontend->templates()->render('page/main/main.html.twig', [
		'message' =>'That TWIG',
		'news' => CMS::orm()->news->range(10)->select()
], 'raw')


$env = new \Techart\Frontend\Environment(new EnvEnvironmentStorage());
$pathResolver = new \Techart\Frontend\PathResolver('./frontend');

$assetsManager = new Techart\Frontend\Assets\Manager($env, $pathResolver);

$templatesManager = new \Techart\Frontend\Templates\Manager(
    new Techart\Frontend\Templates\Repository(
        new Techart\Frontend\Templates\Factory($env, $pathResolver)
    )
);


$assetsManager->cssUrl('index');
$templatesManager->render('page/main/main.html.twig', [
	'message' =>'That TWIG',
	'news' => CMS::orm()->news->range(10)->select()
], 'raw')