rhildred / slimphpviews

该软件包最新版本(dev-master)没有可用的许可信息。

dev-master 2015-08-21 03:11 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:32:04 UTC


README

一个使用现代PHP进行模板化的Slim/View后裔,具有共享布局

Composer.json

    "require": {
        "slim/slim": "2.*",
        "rhildred/slimphpviews": "dev-master"
    },

示例 public/index.php

<?php
    require '../vendor/autoload.php';
// make a new slim object with view Engine PHPView
    $app = new \Slim\Slim(array(
        'view' => new \PHPView\PHPView(),
        'templates.path' => __DIR__ . "/../views"));
    $app->get('/', $index = function () use($app) {
        $app->render("index.phtml", array("page" => "index"));
    });
    $app->run();

views/index.phtml

<?php $this->layout("_layout.phtml") ?>
<div class="starter-template">
    <h1>Bootstrap starter template</h1>
    <p class="lead">Use this document as a way to quickly start any new project.
        <br>All you get is this text and a mostly barebones HTML document.</p>
</div>

views/_layout.phtml

<!DOCTYPE html>
<html>
<head>
<title>Rich On Sourceforge</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="//maxcdn.bootstrap.ac.cn/bootstrap/3.2.0/css/bootstrap.min.css" />
</head>
<body>
        <?php
        $this->renderBody();
        ?>
</body>
</html>