species/app
Composer 安装命令:
composer require species/app
包简介
Yet another Simple Application Framework.
README 文档
README
Yet another Simple Application Framework.
Glue for Slim and Twig, configured with PHP-DI, written in php 7.2!
Installation
There is a skeleton available if you want to start a new project:
composer create-project species/app-skeleton my-project-path
Or use it as a library:
composer require species/app
Middleware
Example how to add middleware with PHP-DI config:
<?php use function DI\add; use Species\App\Middleware; return [ 'settings.middleware' => add([ Middleware\TwigDebugMiddleware::class, Middleware\CsrfValidationMiddleware::class, Middleware\AddRouteNameToTwigMiddleware::class, // ... ]), ];
AddRouteNameToTwigMiddleware
Will add routeName as a twig global variable, if it can find one.
CsrfValidationMiddleware
Will test POST requests if the csrfToken field is valid. When invalid,
the session will be cleared, the session ID will be regenerated and an
InvalidCsrfToken exception will be thrown.
TwigDebugMiddleware
Will add the twig debug extension when twig debug is enabled.
Slim HTTP cache
The slim/http-cache library is also packaged.
Example how to config this middleware:
<?php use function DI\add; use Slim\HttpCache\Cache as HttpCacheMiddleWare; return [ // Default settings 'settings.httpCache.type' => 'private', 'settings.httpCache.maxAge' => 86400, 'settings.httpCache.mustRevalidate' => false, // Add middleware 'settings.middleware' => add([ HttpCacheMiddleWare::class, ]), ];
Twig extensions
Example how to add twig globals and extensions with config:
<?php use function DI\add; use Species\App\TwigExtension; return [ // Twig globals 'settings.twig.globals' => add([ 'foo' => 'bar', // ... ]), // Twig extensions 'settings.twig.extensions' => add([ TwigExtension\CsrfTwigExtension::class, TwigExtension\ReflectionTwigExtension::class, TwigExtension\RouterTwigExtension::class, // ... ]), ];
CsrfTwigExtension
Adds the function csrfTokenInput() to render the hidden input field.
Or use csrfToken() which returns only the token.
ReflectionTwigExtension
Adds the following functions:
fqcn(object $object): stringReturns the fully qualified class name of given object.className(object $object): stringReturns the class name of given object without namespace.instanceOf(object $object, string $class): boolTests if given object is an instance of given class.
RouterTwigExtension
Adds the global baseUrl and following functions:
pathFor(string $name, array $data = [], array $queryParams = []): stringReturns the path for given route.urlFor(string $name, array $data = [], array $queryParams = []): stringReturns the full url for given route.
species/app 适用场景与选型建议
species/app 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 236 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 species/app 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 species/app 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 236
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-12-30