定制 sevenphp/savantphp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sevenphp/savantphp

Composer 安装命令:

composer require sevenphp/savantphp

包简介

Savant (SavantPHP) is a simple and minimalistic, yet object-oriented, Templating System For PHP minimalist. It aims at ONE thing, being a simple lightweight TEMPLATING system. The focus is on ONE thing - PHP can do everything, so do everything with PHP, just use SavantPHP for only separating the 'vi

README 文档

README

SavantPHP is a simple and minimalistic, yet object-oriented, template system for PHP. It aims at ONE thing, being a simple & lightweight TEMPLATING system. We focus only on that ONE thing. PHP can do everything, so do everything with it, just use SavantPHP for only separating the "view/templating" concern from your business logic, that's it.

It has a proper namespace support and installable nicely via composer (unlike it's previous oldish one - see Credit section below)

Unlike other template systems, SavantPHP does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don't need to learn a new markup system and you can use and access any method or functions within your app inside those template.

It is not a competitor to any of the likes of Dwoo or Twig..etc. SavantPHP is for those PHP/templating minimalists - "I just want to separate my front layer(view) from the back layer(code logic)" in the most simple and effective way and that's it, nothing more, nothing less, nothing else (no added crap).

How To Install SavantPHP

$ composer require sevenphp/savantphp

Why Use SavantPHP for Templates?

  • Has namespace support
  • Is installable via composer
  • Is not jammed with lots of wrappers, inbuilt compiling..etc like others
  • The code footprint is small and you can easily follow through the Classes and get the hang of it quickly
  • You don't need to learn a new language or markup to create a template. The template language is PHP, and the template file is a regular PHP file.
  • Because your template script is a regular PHP script, you can sprinkle it with comments and use phpDocumentor to document it.
  • No need to assign variable to an array before you can use it inside your template. The variable usage is direct and simple. (see example code below)

Example:

/* file.php */

use SavantPHP\SavantPHP;
$yourConfigBag = [
    \SavantPHP\SavantPHP::TPL_PATH_LIST => ['/path/to/yourViews/', '/path/to/someOtherFolder/anotherViewFolder/'], //as you can see, set all possible places where your template will reside
    \SavantPHP\SavantPHP::CONTAINER     => $yourContainer //can be anything, e.g a pimple container
];
$tpl = new SavantPHP($yourConfigBag);
$tpl->mynameis = 'Wasseem';

$tpl->setTemplate('file.tpl.php');
$tpl->display(); //or $response = $tpl->getOutput();
/* file.tpl.php | See how other **master templates** are also included within a template */

<html>
<head></head>
<body>
    <p>Hello, my name is <?php if(isset($this->mynameis)) echo $this->escape($this->mynameis) ?></p>

    <?php echo $this->includeTemplate('master/sidebar.tpl.php')?>

<?php echo $this->includeTemplate('master/footer.tpl.php')?>

Voila! Simple huh?

Attention

  • It's your responsibility to filter and sanitize your input. The aim with SavantPHP is only to act as a templating system, the rest is upon you!
  • But I will explain in the incoming documentation / blog post of how you can filter/sanitize your output inside a template file when not possible directly within your code logic.

CHANGELOG

NOTE

  • I have removed the Filter & Plugin System. If you need them, see version tagged v1.0.0
  • see CHANGELOG for all changes, as SavantPHP is NOT backward compatible with the old savant php.

CREDIT

  • This project has been revamped/retouched by me, Khayrattee, on Dec 2015. I'm a die-hard fan of the philosophy of Savant. Thus I took the initiative to fork the old Savant & rework it to keep the spirit of Savant which was started & created by The Mighty 'Paul M. Jones' who is the author of Aura PHP.
  • This project was handed over to Brett Bieber. While I'm sad he is not modernizing the old savant and keeping it abreast, I do understand he might have other priorities and commitments. Anyway, the new SavantPHP is here!
  • This project is hence inspired from [https://github.com/saltybeagle/Savant3]

The Future

  • I have been a big fan and user of the previous Savant PHP. I decided to keep it alive and I'm still using it.
  • I use SavantPHP on a frequent basis and my pet projects fully use it - so I'm going to support it however I can (grateful if YOU contribute too) so that it can be used with the latest tools available & latest PHP version available. This would be very helpful to many of people out there who like me & YOU are inline with the aim above. So do this! cheers.
  • SavantPHP still makes very much sense using as it honors the KISS principle. Consider this SavantPHP Reloaded!

Your Contribution

  • Please help in testing and improving it.
  • Send your pull request on github.
  • And report any bugs either via email (savantphp@7php.com) or via github issues. (thanks guys!)

TODO

  • Add Tests suite
  • See if any further refactoring or performance tweak is needed

sevenphp/savantphp 适用场景与选型建议

sevenphp/savantphp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.88k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 12 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「templating」 「templates」 「views」 「php templating」 「php template」 「php savant」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sevenphp/savantphp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sevenphp/savantphp 我们能提供哪些服务?
定制开发 / 二次开发

基于 sevenphp/savantphp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.88k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 22
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-27