Zend\Expressive\AppFactory::create PHP Method

create() public static method

Will inject the instance with the container and/or router when provided; otherwise, it will use a ZF2 ServiceManager instance and the FastRoute router bridge. The factory also injects the Application with an Emitter\EmitterStack that composes a SapiEmitter at the bottom of the stack (i.e., will execute last when the stack is iterated).
public static create ( Interop\Container\ContainerInterface $container = null, Zend\Expressive\Router\RouterInterface $router = null ) : Application
$container Interop\Container\ContainerInterface IoC container from which to fetch middleware defined as services; defaults to a ServiceManager instance
$router Zend\Expressive\Router\RouterInterface Router implementation to use; defaults to the FastRoute router bridge.
return Application
    public static function create(ContainerInterface $container = null, Router\RouterInterface $router = null)
    {
        $container = $container ?: new ServiceManager();
        $router = $router ?: new Router\FastRouteRouter();
        $emitter = new Emitter\EmitterStack();
        $emitter->push(new SapiEmitter());
        return new Application($router, $container, null, $emitter);
    }

Usage Example

Example #1
0
 public function testFactoryAllowsPassingRouterToUse()
 {
     $router = $this->prophesize('Zend\\Expressive\\Router\\RouterInterface');
     $app = AppFactory::create(null, $router->reveal());
     $test = $this->getRouterFromApplication($app);
     $this->assertSame($router->reveal(), $test);
 }
All Usage Examples Of Zend\Expressive\AppFactory::create