morphable / simple-view
A simple view component, easy to implement into any system
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/morphable/simple-view
Requires
- php: ~7.0
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2025-09-18 07:37:37 UTC
README
A simple view component, easy to implement into any system
Usage
<?php /* * index.php */ use \Morphable\SimpleView; use \Morphable\SimpleView\ViewNotFound; $instance = new SimpleView(__DIR__ . '/views'); /* you can add anything inside the array in the second parameter, for instance a helper class there is no template language, just write however you want inside the views keep in mind the variables you set are usable in the included views after */ $result = $instance->serve("home.php", [ "title" => "hello world", "helper" => new Helper() ]); /* * /views/home.php */ <? $data = $this->getData(); $helper = $data['helper']; ?> <?= $this->include('components/header.php') ?> <? if (isset($data['title'])): ?> <h1><?= $helper->translate($data['title'], 'NL') ?></h1> <? endif; ?> <?= $this->include('components/footer.php') ?>
Contributing
- Follow PSR-2 and the .editorconfig
- Start namespaces with \Morphable\SimpleView
- Make tests