定制 aztech/carnival 二次开发

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

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

aztech/carnival

最新稳定版本:0.1.0

Composer 安装命令:

composer require aztech/carnival

包简介

Create static facades from instances

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage HHVM Support

Carnival is a simple library to generate static facades from instance objects. In other words, it takes an object, hides it behind a generated static class, effectively transforming your object into a singleton as long as you access it from the static facade.

Installation

Composer is the only supported way of installing and using Carnival. From your project's root directory, run:

composer require aztech/carnival

You must then include the Composer autoloader in the entry file of your application:

<?php

require_once __DIR__ . 'vendor/autoload.php';

Dafuq is wrong with you ?

Probably a lot of things. But that fails to answer the question, why this library. Because !

Ok, originally, I wrote it as a troll. But if anyone finds it useful, go ahead, have fun !

And you're using eval ?

Isn't that the root of all evil ? Probably, but it's used in a constrained way, and honestly, if you plan on passing tainted data to Masquerade, allow me to ask dafuq is wrong with you ?

So now that its uselessness is settled, how do I use it anyways ?

Simple, bind whatever object you want to a new, non-existing class name (you can even namespace your facade !) like that:

// This call is only required once, you can place it in your application bootstrap or wherever.
Aztech\Carnival\Masquerade::register(); 

// Bind an object to a class name
Aztech\Carnival\Masquerade::bind('\Facades\SomeArray', new \SplObjectStorage());

// Use your facade
Facades\SomeArray::attach(new \stdClass());

Yup, simple as that.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-09