PHP code example of nixphp / view

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

    

nixphp / view example snippets


$content = view('hello', ['name' => 'World']);

return render('hello', ['name' => 'World']);

return render('pages.hello', ['name' => 'World']);

return render('pages.elements.hello', ['name' => 'World']);

 $this->setLayout('layout') 

<!doctype html>
<html>
<head>
    <title>My App</title>
</head>
<body>
    <?= $this->renderBlock('content') 

<p><?= s($userInput) 

assets()->add('/assets/style.css');            // CSS
assets()->add('/assets/app.js');               // JavaScript (classic)
assets()->add('/assets/main.js', 'module');    // JavaScript ES module

<!doctype html>
<html>
<head>
    <?= assets()->render('css') 

return [
    'view' => [
        'paths' => [
            'views',
            'app/views',
        ],
    ],
];