PHP Classes

File: examples/examplerelative.php

Recommend this page to a friend!
  Classes of Jorge Castro   BladeOne   examples/examplerelative.php   Download  
File: examples/examplerelative.php
Role: Example script
Content type: text/plain
Description: Example script
Class: BladeOne
Standalone template engine that compiles into PHP
Author: By
Last change: * 3.47.3 see changelog.
* 3.47.2 see changelog.
Date: 3 years ago
Size: 1,063 bytes
 

Contents

Class file image Download
<?php
use eftec\bladeone\BladeOne;

if (!isset(
$flag)) {
    die(
"you should call <a href='relative1/relative2/callrelative.php'>relative1/relative2/callrelative.php</a>");
}

include
__DIR__."/../lib/BladeOne.php";


$views = __DIR__ . '/views';
$compiledFolder = __DIR__ . '/compiled';
$blade=new BladeOne($views, $compiledFolder, BladeOne::MODE_DEBUG);

// It is an example, usually baseurl is a fixed value
// However, in this example, we are faking a fixed value by obtaining a value and removing the relative path and parameters
$fullurl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$fullurl=str_replace('relative1/relative2/callrelative.php', '', $fullurl);
$arr=explode('?', $fullurl);
$fullurl=$arr[0];
$blade->setBaseUrl($fullurl);
$blade->addAssetDict(['js/jquery.min.js'=>'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js']);
$blade->addAssetDict(['js/popper.min.js'=>'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js']);


echo
$blade->run("relative.relative", ['baseurl'=>$blade->getBaseUrl()]);