cmdlucas/siler-fork
Composer 安装命令:
composer require cmdlucas/siler-fork
包简介
Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP.
README 文档
README
Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP.
Note:
This is a fork of leocavalcante/siler. Please visit https://github.com/leocavalcante/siler to learn more about the package.
The only addition is the fact that this fork supports type config decorator. It will be taken down once the PR on leocavalcante/siler is merged.
- 💧 Files and functions as first-class citizens
- 🔋 Zero dependency, everything is on top of PHP built-in functions
- ⚡ Blazing fast, no additional overhead - benchmark
Use with Swoole
Flat files and plain-old PHP functions rocking on a production-grade, high-performance, scalable, concurrent and non-blocking HTTP server.
Getting Started
Installation
$ composer require cmdlucas/siler-fork
That is it. Actually, Siler is a library, not a framework (maybe a micro-framework), the overall program flow of control is dictated by you. So, no hidden configs or predefined directory structures.
Or you can start by bootstrapping
$ composer create-project siler/project hello-siler
It's a minimal project template, just with Siler and a convenient serve script:
$ cd hello-siler/
$ composer serve
Hello World
use Siler\Functional as λ; use Siler\Route; Route\get('/', λ\puts('Hello World'));
Nothing more, nothing less. You don't need even tell Siler to run or something like that.
As said before, Siler aims to use PHP files and functions as first-class citizens, so no Controllers here. If you want to call something more self-container instead of a Closure, you can simply give a PHP filename then Siler will require it for you.
index.php
use Siler\Route; Route\get('/', 'pages/home.php');
pages/home.php
echo 'Hello World';
Namespaces
Siler doesn't try to be a fully-featured framework - don't even aim to be a framework - instead it embraces component based architectures and offers helper functions to work with this components under PHP namespaces.
Twig
Is one of the libraries that has helpers functions making work with templates quite simple.
$ composer require twig/twig
use Siler\Functional as F; use Siler\Route; use Siler\Twig; Twig\init('path/to/templates'); Route\get('/', F\puts(Twig\render('template.twig')));
Dotenv
Siler also brings helper functions for vlucas/phpdotenv, so you can easily acomplish twelve-factor apps.
$ composer require vlucas/phpdotenv
.env
TWIG_DEBUG=true
index.php
use Siler\Dotenv; use Siler\Route; use Siler\Twig; Dotenv\init('path/to/.env'); Twig\init('path/to/templates', 'path/to/templates/cache', Dotenv\env('TWIG_DEBUG')); Route\get('/', 'pages/home.php');
Monolog
Monolog sends your logs to files, sockets, inboxes, databases and various web services. See the complete list of handlers here. Special handlers allow you to build advanced logging strategies.
$ composer require monolog/monolog
use Siler\Monolog as Log; Log\handler(Log\stream(__DIR__.'/siler.log')); Log\debug('debug', ['level' => 'debug']); Log\info('info', ['level' => 'info']); Log\notice('notice', ['level' => 'notice']); Log\warning('warning', ['level' => 'warning']); Log\error('error', ['level' => 'error']); Log\critical('critical', ['level' => 'critical']); Log\alert('alert', ['level' => 'alert']); Log\emergency('emergency', ['level' => 'emergency']);
GraphQL
A query language for your API. Thanks to webonyx/graphql-php you can build you Schema from a type definitions string and thanks to Siler you can tie them to resolvers:
$ composer require webonyx/graphql-php
schema.graphql
type Query { message: String } type Mutation { sum(a: Int, b: Int): Int }
index.php
use Siler\Graphql; use Siler\Http\Response; // Enable CORS for GraphiQL Response\header('Access-Control-Allow-Origin', '*'); Response\header('Access-Control-Allow-Headers', 'content-type'); $typeDefs = file_get_contents('path/to/schema.graphql'); $resolvers = [ 'Query' => [ 'message' => 'foo', ], 'Mutation' => [ 'sum' => function ($root, $args) { return $args['a'] + $args['b']; }, ], ]; Graphql\init(Graphql\schema($typeDefs, $resolvers));
MIT 2019
cmdlucas/siler-fork 适用场景与选型建议
cmdlucas/siler-fork 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「api」 「micro」 「router」 「functional」 「swoole」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cmdlucas/siler-fork 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cmdlucas/siler-fork 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cmdlucas/siler-fork 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Anax htmlform module.
Micro Active Record library in PHP, support chain calls, events, and relations.
A PSR-7 compatible library for making CRUD API endpoints
Onix Micro Framework
PHP classes for database handling upon PDO
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-22
