Skip to content

leafsphp/viewi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



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.

Installation

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.

<?php

require __DIR__ . '/vendor/autoload.php';
require __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();

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();:

<?php

use Viewi\PageEngine;

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/viewi-app/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();

Contributing

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

Vano

Casprine

Farhan Yahaya

Lucas Chaplain