承接 enalquiler/instanciate 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

enalquiler/instanciate

Composer 安装命令:

composer require enalquiler/instanciate

包简介

A high order function to instanciate classes passing parameters

README 文档

README

A high order function to instanciate classes passing parameters.

Installation

composer require enalquiler/instanciate

Usage

A simple example

use DateTimeImmutable;
use function Enalquiler\Functional\instanciate;

$fn = instanciate(DateTimeImmutable::class, 'now');
$dateTimeImmutableInstance = $fn(); // Returns an instance of DateTimeImmutable class

A more complex example combining the lazy middleware function, compose function to compose functions, and the awesome functional PHP library to build middleware pipelines using Zend Stratigility

use Http\Factory\Diactoros\ResponseFactory;
use Zend\Diactoros\Response;
use Zend\Stratigility\MiddlewarePipe;
use function igorw\pipeline;
use function Functional\partial_right;

require_once __DIR__ . '/../vendor/autoload.php';

$pipe = new MiddlewarePipe();
$pipe->setResponsePrototype(new Response());

$lazyMiddleware = partial_right(
    pipeline(
        'Enalquiler\Functional\instanciate',
        'Enalquiler\Middleware\lazy'
    ),
    new ResponseFactory()
);

$pipe
    ->pipe($lazyMiddleware(LocaleMiddleware::class))
    ->pipe($lazyMiddleware(SessionMiddleware::class, new \PredisSessionStorage()))
    ->pipe($lazyMiddleware(RedirectionsMiddleware::class))
    ->pipe($lazyMiddleware(AdminMiddleware::class))
    ->pipe($lazyMiddleware(WebMiddleware::class))
    ->pipe($lazyMiddleware(NotFoundMiddleware::class))
;

$server = Server::createServer($app, $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
$server->listen(new Zend\Stratigility\NoopFinalHandler());

Running the tests

php vendor/bin/phpunit

Authors

  • Christian Soronellas
  • Enalquiler Engineering

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固