PHP Lightning Address is an easy way to get a lightning address just with one php script file.
- Prerequisite
- Supported Lightning implementation
- Prerequisite web server configuration
- Usage
- Contributions
- Web server with PHP backend
- LNbits Lightning implementation backend
- Please note that LNbits doesn't need to be on the same server
- You can use https://legend.lnbits.com/ for testing purpose
- Web server must be able to be configured
- to rewrite URL requests
- OR
- to let the PHP backend handle specific file(s) that don't have a
.php
extension
More Lightning implementation will be supported in the future.
Nginx configuration
location /.well-known/lnurlp {
rewrite ^/.well-known/lnurlp/(.*)$ /.well-known/lnurlp/$1.php last;
}
Apache configuration
You need to put a .htaccess
file in the .well-known/lnurlp/
of your web root directory with the following content
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.*) $1.php [L]
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.
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.
Once the web server is configured to rewrite url requests .well-known/lnurlp/anything
to .well-known/lnurlp/anything.php
, lnaddress.php
script needs to be renamed with the wanted username part of the lightning address, such as for a wanted ln address [email protected]
, the script must be named ben.php
.
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.
The following lines (14 & 15) need to be changed according to your api_endpoint
and api_key
that your LNbits wallet provides, be sure to use the invoice/read key.
$backend_options['lnbits'] = [
'api_endpoint' => 'http://localhost:5000', // lnbits endpoint : protocol://host:port
'api_key' => '' // put your lnbits read key here
];
The following variable can be changed
Variable | comment | default value |
---|---|---|
$description |
Description of the payment for the sender | Pay to [email protected] |
$success_msg |
Confirmation message to display on payment success | Payment received! |
$minSendable |
Minimum amount of millisats to send | 100000 |
$maxSendable |
Maximum amount of millisats to send | 10000000000 |
$image_file |
Path to a JPG picture, it will be displayed on the sender confirmation screen | no picture |
Please note that $minSendable
and $maxSendable
do not reflect the actual min/max sendable amount, it depends on the capacity of your LN backend
To add a new lightning address, 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 wanted.
Feel free to open issues & PR if you want to contribute to this project.