File tree Expand file tree Collapse file tree 2 files changed +43
-4
lines changed
Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,47 @@ in pure PHP, implemented the mysql protocol.
2020
2121See examples for usage details.
2222
23+ ## Usage
24+
25+ ### Connection
26+
27+ The ` Connection ` is responsible for communicating with your MySQL server
28+ instance, managing the connection state and sending your database queries.
29+ It also registers everything with the main [ ` EventLoop ` ] ( https://github.com/reactphp/event-loop#usage ) .
30+
31+ ``` php
32+ $loop = React\EventLoop\Factory::create();
33+
34+ $options = array(
35+ 'host' => '127.0.0.1',
36+ 'port' => 3306,
37+ 'user' => 'root',
38+ 'passwd' => '',
39+ 'dbname' => '',
40+ );
41+
42+ $connection = new Connection($loop, $options);
43+ ```
44+
45+ If you need custom connector settings (DNS resolution, TLS parameters, timeouts,
46+ proxy servers etc.), you can explicitly pass a custom instance of the
47+ [ ` ConnectorInterface ` ] ( https://github.com/reactphp/socket#connectorinterface ) :
48+
49+ ``` php
50+ $connector = new \React\Socket\Connector($loop, array(
51+ 'dns' => '127.0.0.1',
52+ 'tcp' => array(
53+ 'bindto' => '192.168.10.1:0'
54+ ),
55+ 'tls' => array(
56+ 'verify_peer' => false,
57+ 'verify_peer_name' => false
58+ )
59+ ));
60+
61+ $connection = new Connection($loop, $options, $connector);
62+ ```
63+
2364## Thanks
2465
2566Thanks to the following projects.
Original file line number Diff line number Diff line change @@ -70,15 +70,13 @@ class Connection extends EventEmitter implements ConnectionInterface
7070 *
7171 * @param LoopInterface $loop ReactPHP event loop instance.
7272 * @param array $connectOptions MySQL connection options.
73- * @param ConnectorInterface $connector (optional) socket sonnector instance.
73+ * @param ConnectorInterface $connector (optional) socket connector instance.
7474 */
7575 public function __construct (LoopInterface $ loop , array $ connectOptions = array (), ConnectorInterface $ connector = null )
7676 {
7777 $ this ->loop = $ loop ;
7878 if (!$ connector ) {
79- $ connector = new Connector ($ loop , [
80- 'dns ' => (new \React \Dns \Resolver \Factory ())->createCached ('8.8.8.8 ' , $ loop )
81- ]);
79+ $ connector = new Connector ($ loop );
8280 }
8381 $ this ->connector = $ connector ;
8482 $ this ->executor = new Executor ($ this );
You can’t perform that action at this time.
0 commit comments