On this page
Class Server
Runs an application invoking all the PSR7 middleware and the registered application.
- Cake\Http\Server implements Cake\Event\EventDispatcherInterface uses Cake\Event\EventDispatcherTrait
Properties summary
Inherited Properties
Method Summary
-
__construct() publicConstructor
-
bootstrap() protectedApplication bootstrap wrapper.
-
emit() publicEmit the response using the PHP SAPI.
- Get/set the application's event manager.
-
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() publicGet/set the application's event manager.
-
setRunner() publicSet the runner
Method Detail
__construct()source public
__construct( Cake\Core\HttpApplicationInterface $app )
Constructor
Parameters
Cake\Core\HttpApplicationInterface$app- The application to use.
bootstrap()source protected
bootstrap( )
Application bootstrap wrapper.
Calls bootstrap() and events() if application implements EventApplicationInterface. After the application is bootstrapped and events are attached, plugins are bootstrapped and have their events attached.
emit()source public
emit( Psr\Http\Message\ResponseInterface $response , Zend\Diactoros\Response\EmitterInterface $emitter = null )
Emit the response using the PHP SAPI.
Parameters
-
Psr\Http\Message\ResponseInterface
$response - The response to emit
-
Zend\Diactoros\Response\EmitterInterface
$emitteroptional null -
The emitter to use. When null, a SAPI Stream Emitter will be used.
eventManager()source public deprecated
eventManager( Cake\Event\EventManager $events = null )
Get/set the application's event manager.
If the application does not support events and this method is used as a setter, an exception will be raised.
Deprecated
3.6.0 Will be removed in 4.0Parameters
Cake\Event\EventManager$eventsoptional null- The event manager to set.
Returns
Cake\Event\EventManager|Cake\Http\Server$this
Implementation of
Cake\Event\EventDispatcherInterface::eventManager()
getApp()source public
getApp( )
Get the current application.
Returns
Cake\Core\HttpApplicationInterfaceThe application that will be run.
getEventManager()source public
getEventManager( )
Get the application's event manager or the global one.
Returns
Cake\Event\EventManagerrun()source public
run( Psr\Http\Message\ServerRequestInterface $request = null , Psr\Http\Message\ResponseInterface $response = null )
Run 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
$requestoptional null - The request to use or null.
-
Psr\Http\Message\ResponseInterface
$responseoptional null - The response to use or null.
Returns
Psr\Http\Message\ResponseInterfaceThrows
RuntimeExceptionWhen the application does not make a response.
setEventManager()source public
setEventManager( Cake\Event\EventManager $events )
Get/set the application's event manager.
If the application does not support events and this method is used as a setter, an exception will be raised.
Parameters
Cake\Event\EventManager$events- The event manager to set.
Returns
$this
setRunner()source public
setRunner( Cake\Http\Runner $runner )
Set the runner
Parameters
Cake\Http\Runner$runner- The runner to use.
Returns
$this
Methods used from Cake\Event\EventDispatcherTrait
dispatchEvent()source public
dispatchEvent( string $name , array|null $data = null , object|null $subject = null )
Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
-
string
$name - Name of the event.
-
array|null
$dataoptional null -
Any value you wish to be transported with this event to it can be read by listeners.
-
object|null
$subjectoptional null -
The object that this event applies to ($this by default).
Returns
Cake\Event\EventMagic methods inherited from Cake\Event\EventDispatcherInterface
Properties detail
$appsource
protected Cake\Core\HttpApplicationInterface
$runnersource
protected Cake\Http\Runner
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.7/class-Cake.Http.Server.html