public function run()
	{
		// Trigger event!
		$this->dispatch($this->listeners[self::LISTENER_STARTUP], [$this]);

		// Create initial request & response (PSR7!)
		$request = $this->createInitialRequest();
		$response = $this->createInitialResponse();

		try {
			// Trigger event!
			$this->dispatch($this->listeners[self::LISTENER_REQUEST], [$this, $request, $response]);

			// Right to the cycle
			$response = call_user_func(
				$this->chain,
				$request,
				$response,
				function (ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
					return $response;
				}
			);

			// Response validation check
			if (!isset($response) || $response === null) {
				throw new RuntimeException('Final response cannot be NULL or unset');
			}
		} catch (Throwable $e) {
			// Trigger event! In case of manual handling error, returned object is passed.
			$res = $this->dispatch($this->listeners[self::LISTENER_ERROR], [$this, $e, $request, $response]);
			if ($res !== null && $res !== false) {
				return $res;
			}

			// Throw exception again if it's not caught
			if ($this->catchExceptions !== true) {
				throw $e;
			}
		}

		// Trigger event! In case of manual finalizing, returned object is passed.
		$res = $this->dispatch($this->listeners[self::LISTENER_RESPONSE], [$this, $request, $response]);
		if ($res !== null && $res !== false) {
			return $res;
		}

		// Send to finalizer (simple send response)
		return $this->finalize($request, $response);
	}
public function run()
	{
		// Trigger event!
		$this->dispatch($this->listeners[self::LISTENER_STARTUP], [$this]);

		// Create initial request & response (PSR7!)
		$request = $this->createInitialRequest();
		$response = $this->createInitialResponse();

		try {
			// Trigger event!
			$this->dispatch($this->listeners[self::LISTENER_REQUEST], [$this, $request, $response]);

			// Right to the cycle
			$response = call_user_func(
				$this->chain,
				$request,
				$response,
				function (ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
					return $response;
				}
			);

			// Response validation check
			if (!isset($response) || $response === null) {
				throw new RuntimeException('Final response cannot be NULL or unset');
			}
		} catch (Throwable $e) {
			// Trigger event! In case of manual handling error, returned object is passed.
			$res = $this->dispatch($this->listeners[self::LISTENER_ERROR], [$this, $e, $request, $response]);
			if ($res !== null && $res !== false) {
				return $res;
			}

			// Throw exception again if it's not caught
			if ($this->catchExceptions !== true) {
				throw $e;
			}
		}

		// Trigger event! In case of manual finalizing, returned object is passed.
		$res = $this->dispatch($this->listeners[self::LISTENER_RESPONSE], [$this, $request, $response]);
		if ($res !== null && $res !== false) {
			return $res;
		}

		// Send to finalizer (simple send response)
		return $this->finalize($request, $response);
	}
public function run ( ) { // Trigger event! $ this -> dispatch ( $ this -> listeners [ self :: LISTENER_STARTUP ] , [ $ this ] ) ; // Create initial request & response (PSR7!) $ request = $ this -> createInitialRequest ( ) ; $ response = $ this -> createInitialResponse ( ) ; try { // Trigger event! $ this -> dispatch ( $ this -> listeners [ self :: LISTENER_REQUEST ] , [ $ this , $ request , $ response ] ) ; // Right to the cycle $ response = call_user_func ( $ this -> chain , $ request , $ response , function ( ServerRequestInterface $ request , ResponseInterface $ response ) : ResponseInterface { return $ response ; } ) ; // Response validation check if ( ! isset ( $ response ) || $ response === null ) { throw new RuntimeException ( 'Final response cannot be NULL or unset' ) ; } } catch ( Throwable $ e ) { // Trigger event! In case of manual handling error, returned object is passed. $ res = $ this -> dispatch ( $ this -> listeners [ self :: LISTENER_ERROR ] , [ $ this , $ e , $ request , $ response ] ) ; if ( $ res !== null && $ res !== false ) { return $ res ; } // Throw exception again if it's not caught if ( $ this -> catchExceptions !== true ) { throw $ e ; } } // Trigger event! In case of manual finalizing, returned object is passed. $ res = $ this -> dispatch ( $ this -> listeners [ self :: LISTENER_RESPONSE ] , [ $ this , $ request , $ response ] ) ; if ( $ res !== null && $ res !== false ) { return $ res ; } // Send to finalizer (simple send response) return $ this -> finalize ( $ request , $ response ) ; }
Dispatch application in middleware cycle!

@return string|int|bool|void|ResponseInterface|null
Dispatch application in middleware cycle!