Viewi integration for Leaf PHP

v0.1.0 2022-08-20 17:15 UTC

This package is auto-updated.

Last update: 2024-05-21 02:07:00 UTC


68747470733a2f2f6c6561667068702e6465762f6c6f676f2d636972636c652e706e67 68747470733a2f2f76696577692e6e65742f6c6f676f2e737667

Leaf Viewi Module

Latest Stable Version Total Downloads License

This module allows you to quickly and easily integrate Viewi into your Leaf apps without any pain at all.


You can easily install Leaf Viewi using the Leaf CLI:

leaf install viewi

Or with Composer.

composer require leafs/viewi

Basic Usage

After installing the module, you can setup a viewi-app/components folder as prescribed by the Viewi docs. In there you can create your Viewi components. Back in your Leaf entry point, all you need to do is initialize the Leaf Viewi module and add your viewi routes.


require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/viewi-app/components/HomePage.php';


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

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


By default, the Leaf Viewi module will handle the configuration for Viewi, so you don't need to anything unless you want to use your own setup. In that case, you can pass the Viewi config into viewi()->init();:


use Viewi\PageEngine;

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/viewi-app/components/HomePage.php';

  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';



We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request 🚀.

To report a security vulnerability, you can reach out to @mychidarko or @leafphp on twitter. We will coordinate the fix and eventually commit the solution in this project.

Code contributors

Ivan Voitovych

Michael Darko

🤩 Sponsoring Leaf

Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.

And to all our existing cash/code contributors, we love you all ❤️

Cash contributors

Aaron Smith

Peter Bogner



Farhan Yahaya

Lucas Chaplain