Skip to content

Modern and fast template engine for PHP, create dynamic views using PHP 8.2 without framework

License

Notifications You must be signed in to change notification settings

victorvelas/echox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Echox PHP

Echox is a library that takes echo for html content to another level.

Installation

Create a new PHP project (or go to the existing project's directory), open your favorite terminal of yesterday and today and run the next Composer command.

composer require velas/echox

Usage

In order to keep the order in your project, Echox has been created to works with a folder shared in all your project, all views that will be rendered by the library must to be in this folder. By default, echox will try to read all views located in views folder, if you want to read another directory you must to specify it using the next code:

use Velas\Echox\Html;
Html::$baseFolder = './your-custom-view-directory/'; // './views/' by default'

You can use any directory to save your view files, however we recommend to use only one directory for the view layer, in order to keep your project files organized an clean

With the renderHTML function, you can keep clean code by separating the business logic and views into different files like this

use function Velas\Echox\Functions\renderHTML;

include './vendor/autoload.php';

/**
 * Some logic
 */

echo renderHtml('presentation', [
    'user' => 'Velas - dev',
    'echoxIsCool' => true
]);

This code will write in buffer out the next code in views/presentation.php file

<h1>Hello World, welcome again <?= ($this->viewData['user'] ?? ''); ?></h1>
<hr>
<?php if ($this->viewData['echoxIsCool'] === true) { ?>
    <p>Now you can write php code like a boss</p>
<?php } ?>

Dou you like it? see more about echox here

About

Modern and fast template engine for PHP, create dynamic views using PHP 8.2 without framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages