morphable / simple-view
A simple view component, easy to implement into any system
v1.0.3-stable
2019-11-17 19:05 UTC
Requires
- php: ~7.0
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-12-18 06:13:01 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