https://github.com/leafsphp/viewi
🚦 Viewi PHP integration for your Leaf apps
https://github.com/leafsphp/viewi
viewi
Last synced: 9 months ago
JSON representation
🚦 Viewi PHP integration for your Leaf apps
- Host: GitHub
- URL: https://github.com/leafsphp/viewi
- Owner: leafsphp
- Created: 2022-08-19T22:09:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-25T02:03:44.000Z (over 1 year ago)
- Last Synced: 2025-04-13T03:24:51.140Z (10 months ago)
- Topics: viewi
- Language: PHP
- Homepage: https://leafphp.dev/modules/views/viewi/
- Size: 9.77 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
Leaf Viewi Module
[](https://packagist.org/packages/leafs/viewi)
[](https://packagist.org/packages/leafs/viewi)
[](https://packagist.org/packages/leafs/viewi)
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](https://cli.leafphp.dev):
```sh
leaf install viewi
```
Or with [Composer](https://getcomposer.org/).
```bash
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
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
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](https://leafphp.dev/community/contributing.html) and you'll be ready to make your first pull request 🚀.
To report a security vulnerability, you can reach out to [@mychidarko](https://twitter.com/mychidarko) or [@leafphp](https://twitter.com/leafphp) on twitter. We will coordinate the fix and eventually commit the solution in this project.
### Code contributors
## 🤩 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](https://opencollective.com/leaf) or check the [contribution page](https://leafphp.dev/support/) 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