PHP code example of leafs / viewi

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

    

leafs / viewi example snippets




e __DIR__ . '/viewi-app/components/HomePage.php';

viewi()->init();

// This is a viewi route.
viewi()->get('/', HomePage::class);

app()->get('/something', function () {
  echo 'This is a Leaf route';
});

app()->run();



use Viewi\PageEngine;

/components/HomePage.php';

viewi()->init([
  PageEngine::SOURCE_DIR => __DIR__ . '/ViewiApp/Components',
  PageEngine::SERVER_BUILD_DIR =>  __DIR__ . '/ViewiApp/build',
  PageEngine::PUBLIC_ROOT_DIR => __DIR__,
  PageEngine::DEV_MODE => true,
  PageEngine::RETURN_OUTPUT => true,
  PageEngine::COMBINE_JS => true
]);

viewi()->get('/', HomePage::class);

app()->get('/something', function () {
  echo 'This is a Leaf route';
});

app()->run();