From Apprentice To Artisan 翻译 02

Respect Boundaries 严守边界

Remember to respect responsibility boundaries. Controllers and routes serve as a mediator between HTTP and your application. When writing large applications, don‘t clutter them up with your domain logic.
记得要保持清晰的责任边界。 控制器和路由是作为HTTP和你的应用程序之间的中间件来用的。当编写大型应用程序时,不要将你的领域逻辑混杂在其中(控制器、路由)。

To solidify our understanding, let‘s write a quick test. First, we‘ll mock the repository and bind it to the application IoC container. Then, we‘ll ensure that the controller properly calls the repository:
为了巩固学到的知识,咱们来写一个测试案例。首先,我们要模拟一个资料库然后绑定到应用的IoC容器里。 然后,我们要保证控制器正确的调用了这个资料库:

public function testIndexActionBindsUsersFromRepository()
{
    // Arrange...
    $repository = Mockery::mock(‘UserRepositoryInterface‘);
    $repository->shouldReceive(‘all‘)->once()->andReturn(array(‘foo‘));
}

asdasd

class a
时间: 2024-10-13 19:37:38

From Apprentice To Artisan 翻译 02的相关文章

From Apprentice To Artisan 翻译 01

Dependency Injection 依赖注入 The Problem 遇到的问题 The foundation of the Laravel framework is its powerful IoC container. To truly understand the framework, a strong grasp of the container is necessary. However, we shold note that an IoC container is simply

From Apprentice To Artisan 翻译 03

The IoC Container 控制反转容器 Basic Binding 基础绑定 Now that we've learned about dependency injection, let's explore inversion of control containers. IoC containers make managing your class dependencies much more convenient, and Laravel ships with a very pow

From Apprentice To Artisan 翻译 04

Reflect Resolution 反射解决方案 One of the most powerful features of the Laravel container is its ability to automatically resolve dependencies via reflection. Reflection is the ability to inspect a classes and methods. For example, the PHP ReflectionClass

Laravel artisan 命令工具

01.php artisan:显示详细的命令行帮助信息,同 php artisan list 02.php artisan –help:显示帮助命令的使用格式,同 php artisan help 03.php artisan –version:显示当前使用的 Laravel 版本 04.php artisan changes:列出当前版本相对于上一版本的主要变化 05.php artisan down:将站点设为维护状态 06.php artisan up:将站点设回可访问状态 07.php

6. Laravel5学习笔记:IOC/DI的理解

介绍 IOC 控制反转 Inversion of Control 依赖关系的转移 依赖抽象而非实践 DI 依赖注入 Dependency Injection 不必自己在代码中维护对象的依赖 容器自动根据配置,将依赖注入指定对象 IOC.DI对于Laravel的意义 Laravel框架的基础是一个功能强大的控制反转容器(IoC container). 为了真正理解该框架,需要好好掌握该容器.然而我们需要了解,控制反转容器只是一种用于方便实现"依赖注入"的工具.但要实现依赖注入并不一定需要

百度刚放假啊数据库风口浪尖萨拉疯了

http://www.ebay.com/cln/l_x5585/2015.02.11/176746639012 http://www.ebay.com/cln/jiacha_boryk/2015.02.11/176837188016 http://www.ebay.com/cln/gbnlin0/2015.02.11/176837189016 http://www.ebay.com/cln/j_j2841/2015.02.11/177066749015 http://www.ebay.com/c

百度房间爱师傅卡卡是快乐疯了;爱死

http://www.ebay.com/cln/shx9479/-/177007606013/2015.02.11 http://www.ebay.com/cln/genqi12/-/176846034010/2015.02.11 http://www.ebay.com/cln/seyyon2/-/176906811016/2015.02.11 http://www.ebay.com/cln/wcn5971/-/176846032010/2015.02.11 http://www.ebay.co

百度和房价是否健康教案上开发

http://www.ebay.com/cln/l.kuan2/-/167247714018/2015.02.10 http://www.ebay.com/cln/setlia-3616/-/167086016019/2015.02.10 http://www.ebay.com/cln/pen-y77/-/167086017019/2015.02.10 http://www.ebay.com/cln/yua-me2/-/167399441016/2015.02.10 http://www.eba

百度电话费健身房拉伸件礼服加拉斯减肥

http://www.ebay.com/cln/cnli_c90nphs5e/-/167379958016/2015.02.07 http://www.ebay.com/cln/gaw4612/-/167226239018/2015.02.07 http://www.ebay.com/cln/re_len4/-/167263594010/2015.02.07 http://www.ebay.com/cln/ta.ku83/-/167162702017/2015.02.07 http://www.