Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$config = new Amp\CodeStyle\Config();
$config->getFinder()->in(__DIR__);

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;
40 changes: 0 additions & 40 deletions .php_cs.dist

This file was deleted.

6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ matrix:
- php: nightly
fast_finish: true

cache:
directories:
- $HOME/.composer/cache
- $HOME/.php-cs-fixer
- $HOME/.local

env:
- AMP_DEBUG=true

Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
}
],
"require": {
"amphp/amp": "^2"
"amphp/amp": "^2",
"amphp/sql": "dev-master"
},
"require-dev": {
"amphp/phpunit-util": "^1",
"phpunit/phpunit": "^6",
"friendsofphp/php-cs-fixer": "^2.3",
"amphp/php-cs-fixer-config": "dev-master",
"phpstan/phpstan": "^0.9"
},
"autoload": {
Expand All @@ -47,7 +48,12 @@
}
},
"scripts": {
"test": "@php -dzend.assertions=1 -dassert.exception=1 ./vendor/bin/phpunit",
"code-style": "@php ./vendor/bin/php-cs-fixer fix"
"check": [
"@cs",
"@test"
],
"cs": "php-cs-fixer fix -v --diff --dry-run",
"cs-fix": "php-cs-fixer fix -v --diff",
"test": "@php -dzend.assertions=1 -dassert.exception=1 ./vendor/bin/phpunit"
}
}
4 changes: 2 additions & 2 deletions examples/basic.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env php
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
require \dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Postgres;

Amp\Loop::run(function () {
/** @var \Amp\Postgres\Connection $connection */
$connection = yield Postgres\connect('host=localhost user=postgres');
$connection = yield Postgres\connect(new Postgres\ConnectionConfig('host=localhost user=postgres'));

/** @var \Amp\Postgres\ResultSet $result */
$result = yield $connection->query('SHOW ALL');
Expand Down
10 changes: 5 additions & 5 deletions examples/listen.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env php
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
require \dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Loop;
use Amp\Postgres;

Loop::run(function () {
$pool = Postgres\pool('host=localhost user=postgres');
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));

$channel = "test";

/** @var \Amp\Postgres\Listener $listener */
$listener = yield $pool->listen($channel);

printf("Listening on channel '%s'\n", $listener->getChannel());
\printf("Listening on channel '%s'\n", $listener->getChannel());

Loop::delay(3000, function () use ($listener) { // Unlisten in 3 seconds.
printf("Unlistening from channel '%s'\n", $listener->getChannel());
\printf("Unlistening from channel '%s'\n", $listener->getChannel());
return $listener->unlisten();
});

Expand All @@ -31,7 +31,7 @@

while (yield $listener->advance()) {
$notification = $listener->getCurrent();
printf(
\printf(
"Received notification from PID %d on channel '%s' with payload: %s\n",
$notification->pid,
$notification->channel,
Expand Down
14 changes: 7 additions & 7 deletions examples/multi-listen.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#!/usr/bin/env php
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
require \dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Iterator;
use Amp\Loop;
use Amp\Postgres;

Loop::run(function () {
$pool = Postgres\pool('host=localhost user=postgres');
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));

$channel1 = "test1";
$channel2 = "test2";

/** @var \Amp\Postgres\Listener $listener1 */
$listener1 = yield $pool->listen($channel1);

printf("Listening on channel '%s'\n", $listener1->getChannel());
\printf("Listening on channel '%s'\n", $listener1->getChannel());

/** @var \Amp\Postgres\Listener $listener2 */
$listener2 = yield $pool->listen($channel2);

printf("Listening on channel '%s'\n", $listener2->getChannel());
\printf("Listening on channel '%s'\n", $listener2->getChannel());

Loop::delay(6000, function () use ($listener1) { // Unlisten in 6 seconds.
printf("Unlistening from channel '%s'\n", $listener1->getChannel());
\printf("Unlistening from channel '%s'\n", $listener1->getChannel());
return $listener1->unlisten();
});

Loop::delay(4000, function () use ($listener2) { // Unlisten in 4 seconds.
printf("Unlistening from channel '%s'\n", $listener2->getChannel());
\printf("Unlistening from channel '%s'\n", $listener2->getChannel());
return $listener2->unlisten();
});

Expand All @@ -53,7 +53,7 @@

while (yield $iterator->advance()) {
$notification = $iterator->getCurrent();
printf(
\printf(
"Received notification from PID %d on channel '%s' with payload: %s\n",
$notification->pid,
$notification->channel,
Expand Down
10 changes: 5 additions & 5 deletions examples/transaction.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env php
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
require \dirname(__DIR__) . '/vendor/autoload.php';

use Amp\Postgres;

Amp\Loop::run(function () {
$pool = Postgres\pool('host=localhost user=postgres');
$pool = Postgres\pool(new Postgres\ConnectionConfig('host=localhost user=postgres'));

yield $pool->query('DROP TABLE IF EXISTS test');

Expand All @@ -15,7 +15,7 @@

yield $transaction->query('CREATE TABLE test (domain VARCHAR(63), tld VARCHAR(63), PRIMARY KEY (domain, tld))');

/** @var \Amp\Postgres\Statement $statement */
/** @var \Amp\Sql\Statement $statement */
$statement = yield $transaction->prepare('INSERT INTO test VALUES (?, ?)');

yield $statement->execute(['amphp', 'org']);
Expand All @@ -26,10 +26,10 @@
$result = yield $transaction->execute('SELECT * FROM test WHERE tld = :tld', ['tld' => 'com']);

$format = "%-20s | %-10s\n";
printf($format, 'TLD', 'Domain');
\printf($format, 'TLD', 'Domain');
while (yield $result->advance()) {
$row = $result->getCurrent();
printf($format, $row['domain'], $row['tld']);
\printf($format, $row['domain'], $row['tld']);
}

yield $transaction->rollback();
Expand Down
12 changes: 0 additions & 12 deletions src/CommandResult.php

This file was deleted.

Loading