1. Go to this page and download the library: Download truecastdesign/true 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/ */
truecastdesign / true example snippets
define('BP', __DIR__);
ecastdesign/true/src/Exceptions.php';
$App = new True\App;
$App->load('site.ini');
if ($App->config->site->debug) {
$GLOBALS['debug'] = true;
error_reporting(E_ALL & ~E_NOTICE);
} else {
$GLOBALS['debug'] = false;
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
}
$App->request = new True\Request;
$App->response = new True\Response;
$App->router = new True\Router($App->request);
$App->view = new True\PhpView;
# global css and js files
$App->view->css = '/vendor/truecastdesign/true/assets/default.css, /assets/css/site.css'; # global css files
# You can also add them on separate lines or different places in your code
$App->view->css = '/assets/example1.css';
$App->view->css = '/assets/example2.css';
# both will be combined and minified. This works for JS files as well.
$App->view->js = '/assets/js/file1.js, /assets/js/file2.js'; # global js files
# If you need to pass variables to the layout template or page template globally, you can use the variables key on the PhpView object as an key value array item.
$App->view->variables = ['key'=>'value'];
$App->view->variables = ['key2'=>'value2'];
$App->view->variables = ['key'=>'value', 'key3'=>'value3'];
# all the arrays will get merged together so you can keep added them and they will all be available. In the view: <?=$key
if ($request->files->file->uploaded) {
// do something like move or resize it
echo $request->files->file->ext; // jpg
echo $request->files->file->mime; // image/jpeg
echo $request->files->file->tmp_name; // /path/j23k4j8d
}
try {
// run method
} catch (Exception $e) {
$App->response('{"result":"error", "error":"'.$e->getMessage().'"}', 'json', 401);
}
$App->response('{"result":"success"}', 'json'); // this will run if the above
// response does not but will not run if there was already a response run above.
$App->view->title = "Title Tag";
$App->view->description = "This is the meta description and og:description";
$App->view->canonical = "http://www.domain.com/canonical-url";
$App->view->linkText = "Clickable Text to link to page";
$App->view->headHtml = "<script src='/path/js/dom/js'></script>";
$App->view->html // page body HTML
$App->view->breadcrumbs // array of breadcrumbs with name and url
// populate using meta area of view file like the following. Only on pages with parent pages. Home is not a parent page according to Google. Put them in decending order from parents down.
// breadcrumb[] = "Top Parent Title|/parent"
// breadcrumb[] = "Next Parent Title|/parent/other-parent"
$App->view->created = "2022-12-01" // set the date the page was created. It can be outputted or used by calling $App->view->created. If you want a different date format, call $App->view->created("M d, Y") can pass the PHP date formatting string you want.
$App->view->modified = "2022-12-01" // You can set the page or article modified date if you want full control of it. This variable will also be auto filled if not provided from the modified date of the view file. Just like the created variable, you can format it by calling $App->view->modified("M d, Y");