PHP code example of renanliberato / exposer

1. Go to this page and download the library: Download renanliberato/exposer 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/ */

    

renanliberato / exposer example snippets


use function RenanLiberato\Exposer\render;
use function RenanLiberato\Exposer\renderComponent;

echo render('li', [
    'href' => '/about',
    'children' => 'Hello!'
]);
// <li href="/about">Hello!</li>

class Profile {
    public function __invoke($props = []) {
        $birthYear = date('Y') - $props['age'];

        return render('div', [
            'style' => [
                'display' => 'flex',
                'align-items' => 'center',
            ],
            'children' => [
                render('p', [
                    'children' => "I am {$props['name']}"
                ]),
                render('p', [
                    'children' => "I was born in {$birthYear}"
                ]),
            ]
        ])
    }
}

echo renderComponent(Profile::class, [
    'name' => 'Renan',
    'age' => 23
])
// <div style="display: flex; align-items: center;">   
//     <p>I am Renan</p>
//     <p>I was born in 1997</p>
// </div>