PHP code example of ttlphp / workerman-fast

1. Go to this page and download the library: Download ttlphp/workerman-fast 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/ */

    

ttlphp / workerman-fast example snippets


/**
 * 示例注解
 * @param string $file
 * @return bool
 * @Register(class='Cache') 注册Cache注解使用
 * @Cache(timeout=600) 此处为有效注解
 */

// 示例
/**
 * @DefineUse(function=true)
 * @DefineParam(name="name", type="string", default="")
 */
class TextAnnotation implements \WorkermanAnnotation\Annotations\iAnnotation {

    /**
     * 注解处理数据生成
     * @param array $params
     * @param array $input
     * @return array
     */
    public function make(array $params, array $input): array {
        return [
            function($params, \Closure $next){ // 返回切入处理器
                // $params 是使用注解的函数参数
                return $next();
            },
            // 返回索引, 可以通过注解处理器索引调用注解函数
            'test' => 'test'
        ];
    }

}