Class Server
Runs an application invoking all the PSR7 middleware and the registered application.
Property Summary
- 
        $_eventClass protectedstringDefault class name for new event objects. 
- 
        $_eventManager protectedCake\Event\EventManagerInterface|nullInstance of the Cake\Event\EventManager this object is using to dispatch inner events. 
- 
        $app protectedCake\Core\HttpApplicationInterface
- 
        $runner protectedCake\Http\Runner
Method Summary
- 
          __construct() publicConstructor 
- 
          bootstrap() protectedApplication bootstrap wrapper. 
- 
          dispatchEvent() publicWrapper for creating and dispatching events. 
- 
          emit() publicEmit the response using the PHP SAPI. 
- 
          getApp() publicGet the current application. 
- 
          getEventManager() publicGet the application's event manager or the global one. 
- 
          run() publicRun the request/response through the Application and its middleware. 
- 
          setEventManager() publicSet the application's event manager. 
Method Detail
__construct() ¶ public
__construct(Cake\Core\HttpApplicationInterface $app, Cake\Http\Runner|null $runner = null)Constructor
Parameters
- 
                Cake\Core\HttpApplicationInterface$app
- The application to use. 
- 
                Cake\Http\Runner|null$runner optional
- Application runner. 
bootstrap() ¶ protected
bootstrap(): voidApplication bootstrap wrapper.
Calls the application's bootstrap() hook. After the application the
plugins are bootstrapped.
Returns
voiddispatchEvent() ¶ public
dispatchEvent(string $name, array $data = [], TSubject|null $subject = null): Cake\Event\EventInterface<TSubject>Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
- 
                string$name
- Name of the event. 
- 
                array$data optional
- Any value you wish to be transported with this event to it can be read by listeners. 
- 
                TSubject|null$subject optional
- The object that this event applies to ($this by default). 
Returns
Cake\Event\EventInterface<TSubject>emit() ¶ public
emit(Psr\Http\Message\ResponseInterface $response, Cake\Http\ResponseEmitter|null $emitter = null): voidEmit the response using the PHP SAPI.
Parameters
- 
                Psr\Http\Message\ResponseInterface$response
- The response to emit 
- 
                Cake\Http\ResponseEmitter|null$emitter optional
- The emitter to use. When null, a SAPI Stream Emitter will be used. 
Returns
voidgetApp() ¶ public
getApp(): Cake\Core\HttpApplicationInterfaceGet the current application.
Returns
Cake\Core\HttpApplicationInterfaceThe application that will be run.
getEventManager() ¶ public
getEventManager(): Cake\Event\EventManagerInterfaceGet the application's event manager or the global one.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Returns
Cake\Event\EventManagerInterfacerun() ¶ public
run(Psr\Http\Message\ServerRequestInterface|null $request = null, Cake\Http\MiddlewareQueue|null $middlewareQueue = null): Psr\Http\Message\ResponseInterfaceRun the request/response through the Application and its middleware.
This will invoke the following methods:
- App->bootstrap() - Perform any bootstrapping logic for your application here.
- App->middleware() - Attach any application middleware here.
- Trigger the 'Server.buildMiddleware' event. You can use this to modify the from event listeners.
- Run the middleware queue including the application.
Parameters
- 
                Psr\Http\Message\ServerRequestInterface|null$request optional
- The request to use or null. 
- 
                Cake\Http\MiddlewareQueue|null$middlewareQueue optional
- MiddlewareQueue or null. 
Returns
Psr\Http\Message\ResponseInterfaceThrows
RuntimeExceptionWhen the application does not make a response.
setEventManager() ¶ public
setEventManager(Cake\Event\EventManagerInterface $eventManager): $thisSet the application's event manager.
If the application does not support events, an exception will be raised.
Parameters
- 
                Cake\Event\EventManagerInterface$eventManager
- The event manager to set. 
Returns
$thisThrows
InvalidArgumentExceptionProperty Detail
$_eventManager ¶ protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
Cake\Event\EventManagerInterface|null