Skip to content

Commit 51eae6a

Browse files
authored
Merge pull request #1 from transistive/testing
updated readme
2 parents 3d6253d + ff2ac91 commit 51eae6a

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Laudis Neo4j PHP Client
22

3-
## Installation and basic usage
4-
5-
### installing
3+
## Installation
64

75
Install via composer:
86

97
```bash
108
composer require laudis/neo4j-php-client
119
```
1210

13-
If you want to use the http protocol but haven't installed any of the psr7, psr17 and psr18 implementations yet:
11+
The HTTP protocol requires [psr-7](https://www.php-fig.org/psr/psr-7/), [psr-17](https://www.php-fig.org/psr/psr-17/) and [psr-18](https://www.php-fig.org/psr/psr-18/) implementations. If there are not any available, composer can install them.
1412

1513
```bash
1614
composer require guzzlehttp/guzzle guzzlehttp/psr7 http-interop/http-factory-guzzle
1715
```
1816

17+
## General usage
18+
1919
### Initializing client
2020

2121
```php
@@ -26,11 +26,11 @@ $client = Laudis\Neo4j\ClientBuilder::create()
2626
->build();
2727
```
2828

29-
The default connection is the first registered connection, unless it is overridden with the `setDefaultConnection` method.
29+
The default connection is the first registered connection. `setDefaultConnection` overrides this behaviour.
3030

3131
### Sending a Cypher Query
3232

33-
Sending a query is done by sending the cypher with optional parameters and a connection alias
33+
Sending a query is done by sending the cypher with optional parameters and a connection alias.
3434

3535
```php
3636
$client->run(
@@ -40,10 +40,11 @@ $client->run(
4040
);
4141
```
4242

43-
Or by using a statement object
43+
Or by using a statement object.
4444

4545
```php
4646
use Laudis\Neo4j\Databags\Statement;
47+
4748
$statement = new Statement('MERGE (user {email: $email})', ['email' => '[email protected]']);
4849
$client->runStatement($statement, 'default');
4950
```
@@ -57,15 +58,15 @@ foreach ($client->run('UNWIND range(1, 9) as x RETURN x') as $item) {
5758
echo $item->get('x');
5859
}
5960
```
60-
will echo `123456789`
61+
will echo `123456789`.
6162

6263
The Map representing the Record can only contain null, scalar or array values. Each array can then only contain null, scalar or array values, ad infinitum.
6364

6465
## Diving Deeper
6566

6667
### Running multiple queries at once
6768

68-
You can run multiple statements at once by simple wrapping a bunch of statements in an iterable object and passing it to the `runStatements` method.
69+
The `runStatements` method will run all the statements at once. This method is an essential tool to reduce the number of database calls.
6970

7071
```php
7172
use Laudis\Neo4j\Databags\Statement;
@@ -76,7 +77,7 @@ $results = $client->runStatements([
7677
]);
7778
```
7879

79-
The results of each query will be wrapped in another vector:
80+
The returned value is a vector containing result vectors.
8081

8182
```php
8283
$results->first(); //Contain the first result vector
@@ -86,7 +87,8 @@ $result->get(1); //Contains the second result vector
8687

8788
### Opening a transaction
8889

89-
Transactions can be started by opening one with the client.
90+
The `openTransaction` method will start a transaction with over the relevant connection.
91+
9092
```php
9193
use Laudis\Neo4j\Databags\Statement;
9294

@@ -97,12 +99,12 @@ $tsx = $client->openTransaction(
9799
);
98100
```
99101

100-
**Note that the optional set of statements will not have their result returned to you, as the transaction will be returned instead**
102+
**Note that `openTransaction` only returns the transaction object, not the results of the provided statements.**
101103

102-
You can then further execute statements on the transaction.
104+
The transaction can run statements just like the client object as long as it is still open.
103105

104106
```php
105-
$result = $tsx->runStatement('MATCH (x) RETURN x LIMIT 100');
107+
$result = $tsx->run('MATCH (x) RETURN x LIMIT 100');
106108
$result = $tsx->runStatement(Statement::create('MATCH (x) RETURN x LIMIT 100'));
107109
$results = $tsx->runStatements([Statement::create('MATCH (x) RETURN x LIMIT 100')]);
108110
```
@@ -117,11 +119,10 @@ $tsx->rollback();
117119
$tsx->commit([Statement::create('MATCH (x) RETURN x LIMIT 100')]);
118120
```
119121

120-
*Note that the optional set of statements provided while comitting the transaction will not return the results.
121122

122123
### Providing custom injections
123124

124-
Each connection can be configured with custom injections.
125+
`addHttpConnection` and `addBoltConnection` each accept their respective injections.
125126

126127
```php
127128
use GuzzleHttp\Client;
@@ -140,17 +141,17 @@ $client = Laudis\Neo4j\ClientBuilder::create()
140141
->build();
141142
```
142143

143-
Custom injections can be wrapped around a callable for lazy initialization as can be found in the example above.
144+
Wrapping the injections in a callable will enforce lazy initialization.
144145

145146
## Final Remarks
146147

147148
### Filosophy
148149

149-
This client tries to strike a balance between extensibility, performance and clean code. All classes are marked final but where there is an interface, injections and decorators can be used.
150+
This client tries to strike a balance between extensibility, performance and clean code. All elementary classes have an interface. These provide infinite options to extend or change the implementation.
150151

151-
I also chose not to implement custom resultsets but use the php-ds extension or polyfill instead. This is because these datastructures are a lot more capable than I will ever be able to make them. Php ds has a consistent interface, works nicely with psalm, has all features you can really want from a simple container and is incredibly fast.
152+
This library does use any custom result classes but uses php-ds instead. These data structures are competent, flexible and fast. It furthermore provides a consistent interface and works seamlessly with other iterables.
152153

153-
Flexibility is maintained where possible by making all parameters iterables if they are a container of sorts. This means you can pass parameters as an array, \Ds\Map or any other object which implements the \Iterator or \IteratorAggregate. These are all valid:
154+
Flexibility is maintained where possible by making all parameters iterables if they are a container of sorts. This means you can pass parameters as an array, \Ds\Map or any other object which implements the \Iterator or \IteratorAggregate. These examples are all valid:
154155

155156
```php
156157
// Vanilla flavour
@@ -199,9 +200,9 @@ $client->run('MATCH (x {slug: $slug})', collect(['slug' => 'a']));
199200

200201
### Cluster support
201202

202-
Version 2.0 will have cluster support. The interface for this is not yet set in stone.
203+
Version 2.0 will have cluster support. There is no concrete API yet.
203204

204-
### Support for graph representation instead of simple records.
205+
### Support for graph representation instead of simple records
205206

206207
Version 2.0 will have graph representation suppport. The inteface for this is not yet set in stone, but will be somthing akin to this:
207208

0 commit comments

Comments
 (0)