PHP code example of klsoft / yii3-swoole

1. Go to this page and download the library: Download klsoft/yii3-swoole library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

klsoft / yii3-swoole example snippets


use Yiisoft\Aliases\Aliases;
use Yiisoft\Assets\AssetManager;
use Yiisoft\Assets\AssetLoaderInterface;
use Yiisoft\Assets\AssetConverterInterface;
use Yiisoft\Assets\AssetRegistrar;

return [
    // ...
    AssetManager::class => [
        'definition' =>  static function (ContainerInterface $container) use ($params): AssetManager {
            $assetManager = new AssetManager(
                $container->get(Aliases::class),
                $container->get(AssetLoaderInterface::class),
                $params['yiisoft/assets']['assetManager']['allowedBundleNames'],
                $params['yiisoft/assets']['assetManager']['customizedBundles'],
            );

            $assetManager = $assetManager
                ->withConverter($container->get(AssetConverterInterface::class));

            if ($params['yiisoft/assets']['assetManager']['publisher'] !== null) {
                $assetManager = $assetManager->withPublisher(
                    $container->get($params['yiisoft/assets']['assetManager']['publisher'])
                );
            }

            $assetManager->registerMany($params['yiisoft/assets']['assetManager']['register']);
            return $assetManager;
        },
        'reset' => function (ContainerInterface $container) {
            $this->registrar = new AssetRegistrar($container->get(Aliases::class), $container->get(AssetLoaderInterface::class));
        },
    ],
];

return [
    // ...
    'klsoft/yii3-swoole' => [
        'swooleServerSettings' => [
             'log_file'   => __DIR__ . '/../../runtime/logs/swoole.log'
        ]
    ],
];

return [
    // ...
    'klsoft/yii3-swoole' => [
        'enableSwooleSsl' => true,
        'swooleServerSettings' => [
            'ssl_cert_file' => __DIR__ . '/../ssl/domain.crt',
            'ssl_key_file' => __DIR__ . '/../ssl/domain.key'
        ]
    ],
];

use Klsoft\Yii3Swoole\SwooleRequestHandlerInterface;
use Psr\Container\ContainerInterface;

return [
    // ...
    SwooleRequestHandlerInterface::class => static function (ContainerInterface $container) {
        return new MySwooleRequestHandler(
            // ...
        );
    }
];