有没有不使用模板的 PHP Web 框架?

发布于 2024-12-07 05:23:50 字数 347 浏览 0 评论 0原文

我正在寻找一个 PHP 框架,它允许我创建 HTML,不是通过像 Smarty 或 Twig 这样的模板系统(我真的不喜欢),而是直接从我的视图类,通过以下方法

$this->elementStart('div', array('id' => 'header',
                                 'class' => 'cls'));
...
$this->elementEnd('div');

: “http://status.net” rel="nofollow">StatusNet 做到了这一点,但它并不是真正的通用框架。有没有这样的框架?

I'm looking for a PHP framework that would allow me to create HTML, not through a templating system like Smarty or Twig (which I really don't like), but directly from my view classes, through methods like:

$this->elementStart('div', array('id' => 'header',
                                 'class' => 'cls'));
...
$this->elementEnd('div');

StatusNet does that, but it's not really a general-purpose framework. Are there any frameworks that work that way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紙鸢 2024-12-14 05:23:50

此时就有非常快的DooPHP。您还可以通过 php 编写自己的模板。但我不认为有什么意义。

At this point there is very fast DooPHP. And you can write your own templating over php. But i dont see a point.

战皆罪 2024-12-14 05:23:50

你可以看看Yii。没有像 Smarty 之类的模板系统,您只有包含 HTML 的视图文件以及从控制器传递的任何 PHP 变量。

编辑:这是我发现的一个旧示例视图,没有链接,所以我只是粘贴了。引用“小部件”等的东西只是框架的组件,而不是模板引擎的东西。

<代码>

    <!-- blueprint CSS framework -->
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
    <!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

    <title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>

<body>

<div class="container" id="page">

    <div id="header">
        <div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
    </div><!-- header -->

    <div id="mainmenu">
        <?php $this->widget('zii.widgets.CMenu',array(
            'items'=>array(
                array('label'=>'Home', 'url'=>array('/site/index')),
                array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
                array('label'=>'Contact', 'url'=>array('/site/contact')),
                array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
                array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
            ),
        )); ?>
    </div><!-- mainmenu -->
    <?php if(isset($this->breadcrumbs)):?>
        <?php $this->widget('zii.widgets.CBreadcrumbs', array(
            'links'=>$this->breadcrumbs,
        )); ?><!-- breadcrumbs -->
    <?php endif?>

    <?php echo $content; ?>

    <div id="footer">
        Copyright © <?php echo date('Y'); ?> by My Company.<br/>
        All Rights Reserved.<br/>
        <?php echo Yii::powered(); ?>
    </div><!-- footer -->

</div><!-- page -->

    </body>
    </html> 

<代码>

You can check out Yii. There isn't a template's system like Smarty or anything, you just have your view files with HTML and whatever PHP variables you pass over from your controllers.

EDIT: Heres an old example view I found, didn't have a link so I just pasted. The stuff referencing "widget" etc is just components of the framework, not template engine stuff.

    <!-- blueprint CSS framework -->
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
    <!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

    <title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>

<body>

<div class="container" id="page">

    <div id="header">
        <div id="logo"><?php echo CHtml::encode(Yii::app()->name); ?></div>
    </div><!-- header -->

    <div id="mainmenu">
        <?php $this->widget('zii.widgets.CMenu',array(
            'items'=>array(
                array('label'=>'Home', 'url'=>array('/site/index')),
                array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
                array('label'=>'Contact', 'url'=>array('/site/contact')),
                array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
                array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
            ),
        )); ?>
    </div><!-- mainmenu -->
    <?php if(isset($this->breadcrumbs)):?>
        <?php $this->widget('zii.widgets.CBreadcrumbs', array(
            'links'=>$this->breadcrumbs,
        )); ?><!-- breadcrumbs -->
    <?php endif?>

    <?php echo $content; ?>

    <div id="footer">
        Copyright © <?php echo date('Y'); ?> by My Company.<br/>
        All Rights Reserved.<br/>
        <?php echo Yii::powered(); ?>
    </div><!-- footer -->

</div><!-- page -->

    </body>
    </html> 

夕色琉璃 2024-12-14 05:23:50

是的,有 Yii 框架..它允许两者。如果您不想应用任何模板调用,请使用 renderPartial() 而不是 render()。
请参考 http://www.yiiframework.com/doc/guide/ 1.1/en/basics.view

yes there is Yii framework.. It allows both. If u dont want to apply any template call use renderPartial() instead of render().
Plz refer to http://www.yiiframework.com/doc/guide/1.1/en/basics.view

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文