lare_team/php_lare

PHP的Lare实现

v1.0.0 2015-06-26 13:12 UTC

This package is not auto-updated.

Last update: 2024-09-22 08:18:29 UTC


README

如何安装php-lare?

安装php-lare只需要两个步骤

  1. 将php-lare添加到你的composer.json中

    {
        "require": {
            "lare_team/php_lare": ">=1.0.0",
        }
    }
  2. 在视图或模板渲染之前设置当前的Lare命名空间

    use Lare_Team\Lare\Lare as Lare;
    ...
    Lare::set_current_namespace('Current.Lare.Namespace');

如何使用php-lare?

这个例子看起来好像有很多冗余,实际上只有if-else标签让它变得复杂。

// View:
if (!Lare::matches('Lare')) {
    // Do everything you need only for the whole site.
}
if (!Lare::matches('Lare.Home')) {
    // Do everything you need to handle the home page.
}

// Head-Template:
if (!Lare::matches('Lare')) {
    <html>
    <head>
    // Scripts and Stylesheets could be loaded here, no need to reload them when changing the page
    <script...
    <link...
<?php } else { ?>
    <lare-head>
<?php }
...
if (!Lare::matches('Lare')) {
    </head>
<?php } else { ?>
    </lare-head>
<?php }

// Body-Template:
if (!Lare::matches('Lare')) {
    <body>
        <header>...</header>
        <div id="site">
            ...
            <div id="page">
<?php } else { ?>
    <lare-body>
<?php }

// Render everything you need in the page container.

if (!Lare::matches('Lare')) { ?>
            </div>
            ...//site content could still be here
            <footer></footer>
        </div>
    </body>
<?php } else { ?>
    </lare-body>
<?php } ?>

如果你觉得这个例子太复杂,可以尝试结合使用twigtwig-lare进行模板设计。

你需要什么来使用php-lare?

  1. PHP >= 5.3.29
  2. lare.js

使用php-lare的项目

  1. iekadou.com

如果你正在使用php-lare,请联系我们,并告诉我们你在哪些项目中使用了它。谢谢!

祝你快乐地加速你的PHP项目!

有关更多信息,请阅读iekadou.com上的php-lare