如何解析可测试控制器的依赖关系?
工作原理:URI路由到Controller,Controller可能具有执行某项任务的依赖关系.
<?php
require 'vendor/autoload.php';
/*
* Registry
* Singleton
* Tight coupling
* Testable?
*/
$request = new Example\Http\Request();
Example\Dependency\Registry::getInstance()->set('request', $request);
$controller = new Example\Controller\RegistryController();
$controller->indexAction();
/*
* Service Locator
*
* Testable? Hard!
*
*/
$request = new Example\Http\Request();
$serviceLocator = new Example\Dependency\ServiceLocator();
$serviceLocator->set('request', $request);
$controller = new Example\Controller\ServiceLocatorController($serviceLocator);
$controller->indexAction();
/*
* Poor Man
*
* Testable? Yes!
* Pain in the ass to create with many dependencies, and how do we know specifically what dependencies a controller …Run Code Online (Sandbox Code Playgroud) 如何在 Phaser 中为精灵装备衣服?假设我使用以下内容:


我能想到的唯一方法是制作每个精灵都打开的图像。一定有不同的方法,比如叠加或者其他什么?