Download the PHP package swentel/nostr-php without Composer

On this page you can find all versions of the php package swentel/nostr-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nostr-php

nostr-php

CI Packagist PHP Version GitHub contributors GitHub issues GitHub last commit (branch)

This is a PHP Helper library for Nostr. More info about Nostr: https://github.com/nostr-protocol/nostr.

Installation

To use the package in your PHP project with Composer:

Install dependencies if you would like to test / code some things out for yourself with the code example snippets below.

Create an event

This will create an event object with a short text message (kind 1).

Signing an event

Generates the id and signature for an event. The 'pubkey', 'id' and 'sig' properties are added to the event object.

Generating a message

Generate an event message : ["EVENT", <event JSON as created above with id and sig>]

Publish an event to a relay

Publish an event with a note that has been prepared for sending to a relay.

If you would like to publish the event to multiple relays, you can use the RelaySet class.

Read events from a relay

Fetch events from a relay.

$response is a multidimensional array with elements containing each a response message (JSON string) decoded to an array from the relay and sorted by the relay. Output example:

Read events from a set of relays

Read events from a set of relays with the RelaySet class. It's basically the same snippet as above with the difference you create a RelaySet class and pass it through the Request object.

Generating a private key and a public key

Converting keys

Convert bech32 encoded keys (npub, nsec) to hex.

Convert hex keys to bech32 (npub, nsec).

Run tests

All tests can be found in tests.

Documentation with phpDocumentor

Generate documentation with phpDocumentor.

All documentation is saved in the phpdoc.nostr-php.dev directory where the index.html can be opened in any browser. This directory also serves as the root directory for https://phpdoc.nostr-php.dev.

The documentation of phpDocumentor can be found at https://docs.phpdoc.org/.

nostr-php script (cli client)

The library ships with a simple CLI client (bin/nostr-php) to post a short text note to a Nostr relay.

Note: the key arguments expects a file with your private key! Do not paste your private key on command line.

Roadmap

Community

If you need any help, please join this Telegram group: https://t.me/nostr_php

Funding

In May 2024 OpenSats granted Sebastian Hagens for further development of this library for one year. If you would like to support this project with a donation, you could send some lightning sats to [email protected] or on-chain to bc1p3p6jq2sxsf650lgllv57st9h97xj37fflg5t8d265saz6yqzcdyqd7pzun.

Maintainers

Contributors

See https://github.com/nostrver-se/nostr-php/graphs/contributors


All versions of nostr-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1 <8.4
ext-gmp Version *
ext-xml Version *
bitwasp/bech32 Version ^0.0.1
phrity/websocket Version ^3.0
simplito/elliptic-php Version ^1.0
uma/phpecc Version ^0.1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package swentel/nostr-php contains the following files

Loading the files please wait ....