Skip to content

Commit ff8dcca

Browse files
committed
Simplify readme
1 parent 3c93df0 commit ff8dcca

File tree

2 files changed

+14
-100
lines changed

2 files changed

+14
-100
lines changed

README.md

Lines changed: 12 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -20,116 +20,29 @@ PHP Lightning Address is an easy way to get a [lightning address](https://lightn
2020
</a>
2121
</p>
2222

23-
### Demo template
24-
25-
Check the **demo template**: [https://github.com/php-lightning/demo-lnaddress](https://github.com/php-lightning/demo-lnaddress)
26-
27-
## Table of contents
28-
29-
- [Prerequisite](#prerequisite)
30-
- [Supported Lightning implementation](#supported-lightning-implementation)
31-
- [Prerequisite web server configuration](#prerequisite-web-server-configuration)
32-
* [Configure web server to rewrite URL](#configure-web-server-to-rewrite-url)
33-
+ [Nginx](#nginx)
34-
+ [Apache](#apache)
35-
* [Without rewriting URL](#without-rewriting-url)
36-
- [Usage](#usage)
37-
* [Rename & move the script to the right directory](#rename--move-the-script-to-the-right-directory)
38-
* [Set API endpoint & API Key](#set-api-endpoint--api-key)
39-
* [Customization](#customization)
40-
* [To add a new address](#to-add-a-new-address)
41-
- [Contributions](#contributions)
42-
43-
## Prerequisite
44-
45-
- [x] Web server with PHP backend
46-
- [x] LNbits Lightning implementation backend
47-
- Please note that **LNbits doesn't need to be on the same server**
48-
- *You can use https://legend.lnbits.com/ for testing purpose*
49-
- [x] Web server **must** be able to be configured
50-
- [x] to rewrite URL requests
51-
- _**OR**_
52-
- [x] to let the PHP backend handle specific file(s) that don't have a `.php` extension
53-
54-
## Supported Lightning implementation
55-
56-
- [LNbits](https://github.com/lnbits/lnbits)
57-
58-
More Lightning implementation will be supported in the future.
59-
60-
## Lightning Address flowchart
61-
62-
<img src="images/lnaddr_workflow.png" alt="Lightning Address flowchart">
63-
64-
# Prerequisite web server configuration
65-
66-
## Configure web server to rewrite URL
67-
68-
### Nginx
23+
## Usage / Development
6924

70-
Nginx configuration
25+
Set up your custom config:
7126

27+
```bash
28+
cp lightning-config.dist.php lightning-config.php
7229
```
73-
location /.well-known/lnurlp {
74-
rewrite ^/.well-known/lnurlp/(.*)$ /.well-known/lnurlp/$1.php last;
75-
}
76-
```
77-
78-
### Apache
7930

80-
Apache configuration
31+
Run a local PHP server listening `public/index.php`
8132

82-
You need to put a `.htaccess` file in the `.well-known/lnurlp/` of your web root directory with the following content
83-
84-
```
85-
RewriteEngine On
86-
RewriteCond %{REQUEST_FILENAME} !-d
87-
RewriteCond %{REQUEST_FILENAME} !-f
88-
RewriteCond %{REQUEST_FILENAME}.php -f
89-
RewriteRule (.*) $1.php [L]
33+
```bash
34+
composer serve
9035
```
9136

92-
Please note that `.htaccess` file will not be read if the Apache configuration doesn't allow configuration overriding, please see Apache documentation regarding `AllowOverride` directive.
93-
94-
## Without rewriting URL
95-
96-
You might be able to configure your web server to let the PHP backend handle specific files, in that way the script can be named without `.php` extension and URL rewriting is thus not needed.
97-
98-
## Usage
99-
100-
### Rename & move the script to the right directory
101-
102-
Once the web server is configured to rewrite url requests `.well-known/lnurlp/anything` to `.well-known/lnurlp/anything.php`, the `index.php` (inside `public/`) script needs to be renamed with the wanted username part of the [lightning address](https://lightningaddress.com/), such as for a wanted ln address `[email protected]`, the script must be named `ben.php`.
103-
104-
Then, the script needs to be in the subdirectory `.well-known/lnurlp/` of your web root directory of your web server such as https://www.yourwebsite.dne/.well-known/lnurlp/ points to your `$WEBROOT/.well-known/lnurlp/` directory.
105-
106-
### Set API endpoint & API Key
107-
108-
The following need to be changed according to your `apiEndpoint` and `apiKey` that your LNbits wallet provides, be sure to use the **invoice/read key**.
37+
### Demo template
10938

110-
```php
111-
# lightning-config.php
112-
return (new LightningConfig())
113-
->setDomain('localhost')
114-
->setReceiver('default-receiver')
115-
->setSendableRange(min: 100_000, max: 10_000_000_000)
116-
->setCallbackUrl('localhost:8000/callback')
117-
->setBackends([
118-
'user-1' => (new LnBitsBackendConfig())
119-
->setApiEndpoint('http://localhost:5000')
120-
->setApiKey('api_key-1'),
121-
'user-2' => (new LnBitsBackendConfig())
122-
->setApiEndpoint('http://localhost:5000')
123-
->setApiKey('api_key-2')
124-
]);
125-
```
39+
We prepared a demo template, so you can use this project as a dependency. The benefits from this approach is that you can easily update your project with `composer update` whenever there are new features or improvements on this `lnaddress` repository.
12640

127-
> **Please note that the `min` and `max` do not reflect the actual min/max sendable amount, it depends on the capacity
128-
of your LN backend**
41+
> [https://github.com/php-lightning/demo-lnaddress](https://github.com/php-lightning/demo-lnaddress)
12942
130-
## To add a new address
43+
## Wiki
13144

132-
To add a new [lightning address](https://lightningaddress.com/), the only thing needed is copying and pasting the script, **don't forget to change the API Key if you want the funds to be received on another wallet**, and name the file with the user part of the [lightning address](https://lightningaddress.com/) wanted.
45+
Check the wiki for more details: [https://github.com/php-lightning/lnaddress/wiki](https://github.com/php-lightning/lnaddress/wiki)
13346

13447
## Contributions
13548

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"psalm": "XDEBUG_MODE=off ./vendor/bin/psalm",
6565
"phpstan": "XDEBUG_MODE=off ./vendor/bin/phpstan analyze",
6666
"csfix": "XDEBUG_MODE=off ./vendor/bin/php-cs-fixer fix",
67-
"csrun": "XDEBUG_MODE=off ./vendor/bin/php-cs-fixer fix --dry-run"
67+
"csrun": "XDEBUG_MODE=off ./vendor/bin/php-cs-fixer fix --dry-run",
68+
"serve": "php -S localhost:8080 public/index.php"
6869
}
6970
}

0 commit comments

Comments
 (0)