小编lk4*_*404的帖子

是否可以在棘轮连接中存储附加变量

这是我的onMessage

public function onMessage(ConnectionInterface $from, $msg) {
    $tempMessage = json_decode($msg, TRUE);
    if ($tempMessage['type'] == 'online') {
        foreach ($this->clients as $client) {
            if ($client == $from) {
                echo "client " . $from->resourceId . "(" . $from->remoteAddress . ") is online\n";
            }
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

是否可以在此 $client 对象中保存值以供以后参考?

我知道可以为此保留一个数组,但它可能会变得复杂,因为我将客户端存储在文档中SplObjectStorage

php websocket ratchet

3
推荐指数
1
解决办法
1234
查看次数

如何在 Laravel 5 中提供自定义验证消息

我一直在关注laravel 4.2,今天尝试了laravel 5。

如何将自定义验证消息添加到 Laravel 5 中的规则?

代码示例

namespace App\Http\Requests;

 
use App\Http\Requests\Request;
 

class MyRequest extends Request {


    /**

     * Determine if the user is authorized to make this request.

     *

     * @return bool

     */

    public function authorize()

    {

        return true;

    }

 

    /**

     * Get the validation rules that apply to the request.

     *

     * @return array

     */

    public function rules()

    {

        return [

            'email' => 'required|email',

            'password' => 'required|min:8'

        ];

    }

}
// in your controller action
public function postLogin(\App\Http\Requests\MyRequest …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

1
推荐指数
1
解决办法
3381
查看次数

标签 统计

php ×2

laravel ×1

laravel-5 ×1

ratchet ×1

websocket ×1