PHP code example of takemo101 / laravel-simple-templa

1. Go to this page and download the library: Download takemo101/laravel-simple-templa 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/ */

    

takemo101 / laravel-simple-templa example snippets


// Get Template object
$template = \SimpleTempla::template('{{ data.a }} {{ data.b }}');

// Run parse
echo $template->parse([
    'data' => [
        'a' => 'hello',
        'b' => 'world',
    ],
]);
// hello world

// Run parse immediately
echo \SimpleTempla::parse(
    '{{ data.a }} {{ data.b }}'),
    [
        'data' => [
            'a' => 'hello',
            'b' => 'world',
        ],
    ]
);
// hello world


namespace App\Scaffolds;

use Takemo101\LaravelSimpleTempla\Scaffold\Scaffold;

// Must inherit from Scaffold class
class DemoScaffold extends Scaffold
{
    /**
     * Constructor injection is possible
     */
    public function __construct()
    {
        //
    }

    /**
     * get need command option validation rules
     *
     * @return string[]
     */
    public function rules(): array
    {
        return [
            'name' => '


// ./resources/stub/Entity.stub

namespace Stub\Entity\Demo{{ name|ucfirst }};

class Demo{{ name|ucfirst }}Entity
{
    /**
     * @var string
     */
    private string $name = '{{ key|lower }}';
}


// ./config/simple-sample.php

return [
    ...
    'scaffolds' => [
        'demo' => App\Scaffolds\DemoScaffold::class,
    ],
]

php artisan vendor:publish --tag="simple-templa"

php artisan make:scaff ClassName

php artisan simple-templa:exec demo