You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 4, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+59-7Lines changed: 59 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# php-electrum-api - Electrum library with no dependencies
1
+
# php-electrum-api - Electrum library
2
2
```
3
3
Licence: GPL-3.0
4
4
Author: Pascal Krason <p.krason@padr.io>
5
-
Language: PHP 5.6
5
+
Language: PHP 5.6-7.1
6
6
```
7
-
Please note, this library is by far not completed and production ready, there are still a lot methods which aren't neither tested or even implemented.
7
+
Please note, this library is by far not completed and but can be used in production. Until now i only implemented the most commonly used API-Calls. If you think im missing something, just create an issue or fork the project.
8
8
9
9
# Setting up Electrum
10
10
First you need to setup a new Electrum wallet. Follow the instructions according to your OS at the [Electrum Download Page](https://electrum.org/#download). After the successfull installation you need to set a rpcport by typing:
@@ -19,9 +19,13 @@ Now we can go ahead and start Electrum in daemon mode:
19
19
```
20
20
electrum daemon start
21
21
```
22
+
Since some new version electrum wants you to load your wallet by hand on startup:
23
+
```
24
+
electrum daemon load_wallet
25
+
```
22
26
23
27
# Requirements
24
-
On the PHP side there are not much requirements, you only need atleast PHP 5.6 and the curl-Extension installed. Optional you need [Composer](http://getcomposer.org)to install this library.
28
+
On the PHP side there are not much requirements, you only need at least PHP 5.6 and the curl-Extension installed. Then you can go ahead ans it through [Composer](http://getcomposer.org)which will do everything else for you.
25
29
26
30
# Install
27
31
First you need to install [Composer](https://getcomposer.org/doc/00-intro.md), after you accomplished this you can go ahead:
@@ -32,8 +36,56 @@ Then you can simply include the autoloader and begin using the library:
32
36
```php
33
37
// Include composer autoloader
34
38
require_once 'vendor/autoloader.php';
39
+
```
40
+
41
+
# Examples
42
+
43
+
## Basic example
44
+
A very basic useage example. Every API-Call has it's own request-object. You simply create one and execute it.
45
+
```php
46
+
47
+
$method = new \Electrum\Request\Method\Version();
48
+
49
+
try {
50
+
$response = $method->execute();
51
+
} catch(\Exception $exception) {
52
+
die($exception->getMessage());
53
+
}
35
54
36
-
// Create new instance
37
-
$electrum = new \Electrum\Client('http://127.0.0.1/', 7777);
38
-
$electrum->getVersion();
55
+
$response->getVersion();
39
56
```
57
+
58
+
## Custom Client Configuration
59
+
Every Request/Method takes a `Electrum\Client`-instance as parameter which replaces the default one. A custom instance can be usefull if you want to set custom config params like another Hostname or Port.
60
+
```php
61
+
$client = new \Electrum\Client('http://127.0.0.1', 7777);
62
+
$method = new \Electrum\Request\Method\Version($client);
63
+
64
+
try {
65
+
$response = $method->execute();
66
+
} catch (\Exception $exception) {
67
+
die($exception->getMessage());
68
+
}
69
+
70
+
$response->getVersion();
71
+
```
72
+
73
+
## Advanced exception handling
74
+
Dealing with exceptions is easy. You can catch two types of exceptions which indicates whether it's an Request or Response fault.
0 commit comments