bndrmrtn/flamephp_engine

There is no license information available for the latest version (dev-main) of this package.

Drop the old PHP <?= syntax and never use it again, the solution is *.flame.php wich converts {{ $title }} to <?php echo $title ?> and @foreach(...) ... @endforeach to <?php foreach(...): ?> ... <?php endforeach ?>, so UI development is not a PAIN anymore with flamephp_engine

dev-main 2023-11-14 11:54 UTC

This package is auto-updated.

Last update: 2025-06-14 15:03:57 UTC


README

How to add to a project?

Install it via composer and add it to your file.

composer require bndrmrtn/flamephp_engine:dev-main
require_once 'vendor/autoload.php';

Configure or use the default config

use Bndrmrtn\FlamephpEngine\FlamePHP;
use Bndrmrtn\FlamephpEngine\FlamePHP\Config;

$flame = new FlamePHP(
     viewsDirectory: '...', // The directory where you store your views
     useDevelopmentMode: true, // Your project is in development mode or not
     cacheDirectory: '...',  // The directory where you want to store your cache data
     config: new Config, // Custom config, or use the default
);

How to use it?

You can use it with *.flame.php files with a directory named views in your root folder, or the parseString option that doesn't requires any file. (Except the cache files that auto generated by this tool).

Code examples

With the textParser option

use Bndrmrtn\FlamephpEngine\FlamePHP;

$flame = new FlamePHP;

$flame->parseString('
     <h1>Hello {{ $world }}</h1>
', ['world' => 'Developer'],
);

// <h1>Hello Developer</h1>

With the file option

// ...
$flame->includeFile(
     'filename', // without the .flame.php extension!
     ['name' => 'John'] // add props to it
);

Actually you can get the path of the file's cache with the parseFile method, like this:

// ...

$parsed_file = $flame->parseFile(
     'filename', // without the .flame.php extension!
     // No props here
);

echo $parsed_file; // output: C:\...\your_project\flamephp_engine\cache\views\filename.flame.php

Demo

You can check the /tests folder and run the tests with PHPUnit

Documentation

Here FlameCore Official Views Documentation you can find a small documentation of how it works, but I must remind you that it documents a modified version and that you should follow the default settings as described above!

Credits

Martin Binder, FullStack Web Developer, 4 years of experience with PHP, 3 with Laravel. Currently I am learning GoLang ;)