Built-in Events

Swoft built-in events, Swoole-based callback processing, extends some of the available server events and the basics of starting the runtime to enhance customization

Server Events

Swoole-based callback processing extends some of the available server events and provides more granular operating space.

  • ServerEvent::BEFORE_SETTINGBefore calling the method of Swoole server setting()
  • ServerEvent::BEFORE_BIND_EVENTBefore calling the on() method binding Swoole callback for Swoole server
  • ServerEvent::BEFORE_STARTBefore calling the Swoole server start() method to start the server
  • ServerEvent::TASK_PROCESS_STARTTriggered only when the task process of Swoole server starts
  • ServerEvent::WORK_PROCESS_STARTTriggered only when the Swoole server's progress process starts
<?php declare(strict_types=1);

namespace Swoft\Server;

/**
 * Class ServerEvent
 *
 * @since 2.0
 */
final class ServerEvent
{
    /**
     * Before set swoole settings
     */
    public const BEFORE_SETTING = 'swoft.server.before.setting';

    /**
     * Before bind swoole events
     */
    public const BEFORE_BIND_EVENT = 'swoft.server.bind.event';

    /**
     * Swoft before start server event
     */
    public const BEFORE_START = 'swoft.server.start.before';

    /**
     * On task process start event
     */
    public const TASK_PROCESS_START = 'swoft.process.task.start';

    /**
     * On work process start event
     */
    public const WORK_PROCESS_START = 'swoft.process.work.start';

    /**
     * on user process start event
     */
    public const USER_PROCESS_START = 'swoft.process.user.start';
}

Swoft Basic Events

Provides some special events within the Swoft startup initialization completion, as well as some swoft

  • SwoftEvent::APP_INIT_COMPLETETriggered when Swoft initialization is complete (the configuration is loaded and the container has been initialized)
<?php declare(strict_types=1);

namespace Swoft;

/**
 * Class SwoftEvent
 * @since 2.0
 */
final class SwoftEvent
{
    /**
     * Swoft init complete
     */
    public const APP_INIT_COMPLETE  = 'swoft.init.complete';

    /**
     * Session complete
     *  - webSocket connection close
     */
    public const SESSION_COMPLETE = 'swoft.session.complete';

    /**
     * Coroutine complete
     */
    public const COROUTINE_COMPLETE = 'swoft.co.complete';

    /**
     * Coroutine destroy
     */
    public const COROUTINE_DESTROY = 'swoft.co.destroy';

    /**
     * Coroutine defer
     */
    public const COROUTINE_DEFER = 'swoft.co.defer';

    /**
     * Worker shutdown
     */
    public const WORKER_SHUTDOWN = 'swoft.worker.shutdown';
}
/docs/2.x/en/event/swoft-events.html
progress-bar