朕的大清完了

朕的大清完了

这家伙有点懒,还没写个性签名!

  • 财富值479
  • 威望值20
  • 总积分899

个人信息

  • 2019-03-18 已签到
    连续签到5天,获得了20个金钱
  • 赞了回答

    这个容易,其实网站里也有了,你没有看而已,这次你去看 DbDependency 的api就对了。你说是不是。

    https://www.yiichina.com/doc/api/2.0/yii-caching-dbdependency#$db-detail

    看到这个依赖对象的属性了吗?你试试把你上面的代码改下:

    $dep=new \yii\caching\DbDependency([
        'sql'=>'select max(reg_date) from {{%account}}',
        'db'=>'db2'//db2可以是一个新的数据库连接组件名字,或者直接配置数组也行
    ]);
    

    你看到了吗?你想知道的,都可以在这个网站找到,其实你如果会找了,这些还是啥大问题吗?

  • 回复了 的回答

    这个容易,其实网站里也有了,你没有看而已,这次你去看 DbDependency 的api就对了。你说是不是。

    https://www.yiichina.com/doc/api/2.0/yii-caching-dbdependency#$db-detail

    看到这个依赖对象的属性了吗?你试试把你上面的代码改下:

    $dep=new \yii\caching\DbDependency([
        'sql'=>'select max(reg_date) from {{%account}}',
        'db'=>'db2'//db2可以是一个新的数据库连接组件名字,或者直接配置数组也行
    ]);
    

    你看到了吗?你想知道的,都可以在这个网站找到,其实你如果会找了,这些还是啥大问题吗?

    谢谢大佬。

  • 大佬有swoole还有必要用nginx吗,swoole伪静态规则怎么写

    嗯嗯,谢谢大佬,nginx才能管理站点,swoole 纯粹就一个服务没那么多功能

  • 发表了说说
    以为php也就做做web之类的,有了swoole真的是无所不能了。不可置信的是居然是国人开发的扩展,厉害了。
  • 2019-03-17 已签到
    连续签到4天,获得了20个金钱
  • 回复了 的评论

    没用基础版版测试,但简单来说,你可以这么干,把配置文件都挪出来放到启动脚本websocket-server里:

    #!/usr/bin/env php
    <?php
    
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_ENV') or define('YII_ENV', 'dev');
    defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
    defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
    defined('STDERR') or define('STDERR', fopen('php://stderr', 'w'));
    
    require __DIR__ . '/vendor/autoload.php';
    require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
    
    //require __DIR__ . '/common/config/bootstrap.php';
    //require __DIR__ . '/websocket/config/bootstrap.php';
    //$config = yii\helpers\ArrayHelper::merge(
    //    require __DIR__ . '/common/config/main.php',
    //    require __DIR__ . '/common/config/main-local.php',
    //    require __DIR__ . '/websocket/config/main.php',
    //    require __DIR__ . '/websocket/config/main-local.php'
    //);
    
    Yii::setAlias('@immusen/websocket', __DIR__ . '/vendor/immusen/yii2-swoole-websocket');
    Yii::setAlias('@websocket', __DIR__ . '/websocket');
    $config = [
        'id' => 'websocket',
        'basePath' => __DIR__ . '/websocket',
        'bootstrap' => ['log'],
        'controllerNamespace' => 'websocket\controllers',
        'components' => [
            'errorHandler' => ['class' => 'yii\console\ErrorHandler'],
            'log' => [
                'targets' => [
                    [
                        'class' => 'yii\log\FileTarget',
                        'levels' => ['error', 'warning'],
                    ],
                ],
            ],
        ],
        'params' => [
            'listen' => 8721,
            'daemonize' => 0,
            'redis' => [
                'host' => '127.0.0.1',
                'port' => '6379',
    //        'auth' => 'passwd',
                'pool_size' => 10,
            ],
        ],
    ];
    
    $application = new immusen\websocket\Application($config);
    $exitCode = $application->run();
    exit($exitCode);
    
    

    谢谢回复。

  • 大佬今天我用了下,貌似这个是高级版的,没有基础版的吗。。
    启动服务就报错了

    想着注释掉,但是引用的太多了,都不知道路径,麻烦大佬出个基础版的吧,

    21.png

    123.png

  • 大佬有swoole还有必要用nginx吗,swoole伪静态规则怎么写

主管 等级规则
899/1000
资料完整度
10/100
用户活跃度
20/100

Ta的关注

0

Ta的粉丝

2

Ta的访客

31