Nostr-PHP

https://nostr-php.dev

#PHPisDead

Image
PHP is dead

#PHPisDead. Also what I wrote in my OpenSats application for building the Nostr-PHP libary back in January 2024.

Read the application: https://nostrver.se/blog/opensats-application-nostr-helper-library-php

"But wait, isn’t PHP dead?
Nope, it’s still alive and kicking.

  • PHP is used by 76.7% of all websites
  • Many FOSS projects are built with PHP
  • With the age of 28 years, PHP probably exist the next 28 years (Lindy effect)
  • Most used CMSs are built with PHP and used by many organizations and individuals"

Number of Nostr-PHP installs:

Source: https://packagist.org/packages/swentel/nostr-php/stats#major/1

Tags

A very, very late after summer holidays update

Nostr-PHP

Before my holidays I met with Djuri to discuss establishing a co-maintainership for the Nostr-PHP helper library.

Since June 12th I haven't submitted a commit on the master branch.

Packagist stats show around 30 installs per day, which confirms real-world usage. GitHub stars are also steady, indicating growing interest in the project.

Star History Chart

My OpenSats grant has ended for Nostr-PHP

My OpenSats grant for Nostr-PHP has ended. It began in May 2024 and included a 3-month pause earlier this year; the grant period for building and maintaining the library is finished.  But I’m not quitting. I will carry the responsibility as a maintainer forward. The plan is to apply for a new grant to keep developing the library and the dependent projects. However, with my client backlog right now, I’m not sure I’ll have enough time to devote to Nostr-PHP and the related work.

Operation Kidstr + kubo.watch

In my spare time working on Nostr stuff, this will be the project I focus on most in the coming months. Why? I’ve dropped notes before on ideas for a YouTube Kids alternative (here, here). 

Working with others on it, it’s my responsibility to develop a demo. I’m building the demo with Drupal, using Nostr-PHP to nostrify different types of events. Make sure to read these articles to:

Remote signers (aka bunkers)

There are many unexplored territories in the Nostr ecosystem, and the area around remote signers is one of them. Let me start by listing some remote signers / NIP-46 implementations you can use today.

While working on Kidstr and hashing out ideas with Constant, I can see a few ways we could build smarter remote signers. Yes, it would add some complexity, but most of that is already handled by clients. We all know Nostr isn’t exactly easy to use yet, so maybe we can reduce the complexity by using remote signers that take care of the heavy lifting. So… I’ve got some boiling ideas in my head.

CCNS.news updates

After upgrading Tailwind CSS to the latest major version (from v3.4 to v4.1) I to fixed some minor styling issues.

I’ve integrated Web Push Notifications via the Push Framework Notifications module. This is a module which I started to co-develop two years ago for other projects. 

You can read a full technical deep-dive on my blog A deep-dive into Web Push Notifications with Drupal using Push Framework Notifications.

In the PWA, you can subscribe when new comments are posted under a specific link or bookmark. When someone drops a new comment, you’ll get a push notification. Logged-in users can post comments, but I still need to nostrify these comments by transmitting them as kind 1111 events. Login with your Nostr profile in the PWA isn’t wired up yet. That’s a bigger hurdle, because I’d either need to integrate NIP-46 for remote signing (or, less ideally, fall back to using an nsec, which is a known bad practice).

Stuff building for Drupal

See Ecosystem modules for Nostr.

nostr_event

This module renders Nostr events that are saved in the Drupal database. In the admin area, I also added a route that loads a form where you can copy-paste an event ID, fetch the event, and save it as a Nostr event entity.

nostr_profile

This extends user entities in Drupal with a dedicated Nostr profile. In this profile, you can add or update your Nostr keys and metadata (todo).

nostr_wallet_connect

This integrates the Nostr-PHP-NWC package.

nostr_applesauce

A piece of middleware which you can use to add the AppleSauce SDK (Javascript) to your Drupal website.

Nyves

While this is one of my favorite projects to work on, I won’t have much time to push it forward in the coming months.

So thanks for bearing with me. Hyves coming back via Nostr might have to wait a bit longer ;-).

FOSDEM 2026 is coming

I will just drop this note here.

nostr:nevent1qvzqqqqqqypzqpnrnguxe8qszsshvgkvhn6qjzxy7xsvx03rlrtddr62haj4lrm3qqs99ddnrppvhhkaew4qsvxpj50z9fncllhzgpxdzwft3etfyy9pphsh78qw7

Other stuff

Just another idea: a highlights page showing my kind 9802 and kind 39701 events. You might seen a new menu link on nostrver.se: Highlights. Check it out ;-)

I need to migrate my Nostr infrastructure to a new server, but I haven’t picked a provider yet that can offer a decent VPS.

Tags

Week 12 + 13 updates: NIP-19 in Nostr-PHP

Image
NIP-19

You can follow the work in progress here in this pull request https://github.com/nostrver-se/nostr-php/pull/68 on Github.

Before my 3-month break (Dec/Jan/Feb) working on Nostr-PHP I started with the NIP-19 integration in October '24. Encoding and decoding the simple prefixes (npub, nsec and note) was already done in the first commits.

Learn more about NIP-19 here: https://nips.nostr.com/19 

TLV's

Things were getting more complicated with the other prefixes / identifiers defined in NIP-19:

  • nevent
  • naddr
  • nprofile

This is because these identifiers contain (optional) metadata called Type-Lenght-Value aka TLV's.

When sharing a profile or an event, an app may decide to include relay information and other metadata such that other apps can locate and display these entities more easily.

For these events, the contents are a binary-encoded list of _TLV_ (type-length-value), with _T_ and _L_ being 1 byte each (_uint8_, i.e. a number in the range of 0-255), and _V_ being a sequence of bytes of the size indicated by _L_.

These possible standardized TLV types are:

  • 0: special
    • depends on the bech32 prefix:
      • for nprofile it will be the 32 bytes of the profile public key
      • for nevent it will be the 32 bytes of the event id
      • for naddr, it is the identifier (the "d" tag) of the event being referenced. For normal replaceable events use an empty string.
  • 1: relay
    • for nprofile, nevent and  naddr, optionally, a relay in which the entity (profile or event) is more likely to be found, encoded as ascii
    • this may be included multiple times
  • 2: author
    • for naddr, the 32 bytes of the pubkey of the event
    • for nevent, optionally, the 32 bytes of the pubkey of the event
  • 3: kind
    • for naddr, the 32-bit unsigned integer of the kind, big-endian
    • for nevent, optionally, the 32-bit unsigned integer of the kind, big-endian

These identifiers are formatted as bech32 strings, but are much longer than the package bitwasp/bech32 (used in the library) for can handle for encoding and decoding. The bech32 strings handled by bitwasp/bech32 are limited to a maximum length of 90 characters.

Thanks to the effort of others (nostr:npub1636uujeewag8zv8593lcvdrwlymgqre6uax4anuq3y5qehqey05sl8qpl4 and nostr:npub1efz8l77esdtpw6l359sjvakm7azvyv6mkuxphjdk3vfzkgxkatrqlpf9s4) during my break, some contributions are made (modifiying the bech32 package supporting much longer strings, up to a max of 5000 characters). At this moment, I'm integrating this (mostly copy-pasting the stuff and refactoring the code):

So what's next?

  • NIP-19 code housekeeping + refactoring
  • Prepare a new release with NIP-19 integration
  • Create documentation page how to use NIP-19 on https://nostr-php.dev

Nostr-PHP helper library 90-day OpenSats report #2

Image
OpenSats

1) How did you spend your time?

I continued to write and publish more detailed weekly updates here: https://nostrver.se/blog. These updates are also cross-posted via Nostr as long-form content.

Integrated RelayResponse classes

Pull requests:

Documentation: https://nostr-php.dev/guides/relay-responses

Researched and build a proof of concept of a handling async requests and concurrency

I have published the research outcomes here: https://nostr-php.dev/references/async-concurrent-requests.   I also created a page here https://nostr-php.dev/guides/asynchronous-and-concurrent-requests with more details and a code snippet. The famous Http/Guzzle client is used for handling the requests in combination with a relative new piece of middleware which enables WebSockets. See https://github.com/valtzu/guzzle-websocket-middleware/issues/1 where I reached out for solving an issue with the middleware.

NIP-42 client to relay authentication

Finished, see https://github.com/nostrver-se/nostr-php/pull/67 

NIP-19 bech32-encoded entities

Work in progress, see https://github.com/nostrver-se/nostr-php/pull/68 

2.0.0 pre-release

See https://github.com/nostrver-se/nostr-php/releases/tag/2.0.0-alpha1 

Other stuff

2) What do you plan to work on next quarter?

  • Finish the NIP-19 implementation which will support every bech32 entity
    • note
    • npub
    • nsec
    • nevent
    • naddr
    • nprofile
  • Research how the revolt/event-loop package can be used to serve as a sort of a message bus for handling async and concurrent requests in the library
  • Build a final 2.0.x release
    • By default and full async concurrent requests support
  • Implement NIP-03
  • Implement NIP-45
  • Implement a firehose demo for requesting Nostr events
  • Host the nostr-php.dev website as a static website with Blossom on Nostr. See https://github.com/lez/nsite and https://github.com/hzrd149/nsite-ts

3) How did you make use of the money?

4) Is there anything we could help with?

I would love to see a (closed/private) digital place with other Nostr OpenSats grantees where we can share our experiences and challenges. We could give feedback to each other as a form of encouragement. For example I'm curious how other grantees are explaining the work they to other which are not familiar with FOSS, Nostr and/or Bitcoin.

Tags

Week 38 updates

Here is code snippet: https://gist.github.com/Sebastix/5991b84334c6c7e12bc28b2e703311b6 

OpenSats application for Nostr helper library for PHP

Image
PHP

Further development of the Nostr helper library for PHP

Problem

> 👉 There is no easy way for PHP developers to integrate Nostr in PHP powered websites and applications.

To let the adoption of Nostr grow, it needs to be integrated into the web as it exists today with the many PHP powered websites and applications.

But wait, isn’t PHP dead?

Nope, it’s still alive and kicking.

  • PHP is used by 76.7% of all websites
  • Many FOSS projects are built with PHP
  • With the age of 28 years, PHP probably exist the next 28 years (Lindy effect)
  • Most used CMSs are built with PHP and used by many organizations and individuals
    More stats on PHP: https://w3techs.com/technologies/details/pl-php

When there is useful and powerful Nostr integration with PHP, developers building PHP powered applications and platforms will create a springboard towards more Nostr adoption.

WordPress, Drupal and other PHP powered platforms

I advocate that Nostr needs integration with existing well-built and well-adopted tools. Drupal is a leading Web Content Management System that powers some of the largest websites and is one of those tools where Nostr can really shine. If we look even broader, there are many existing PHP powered applications on the web which can benefit with a Nostr integration, such as WordPress.

nostr-php package

A Nostr helper library for PHP

There are not many PHP packages for Nostr yet: https://packagist.org/?query=nostr. When all those PHP websites have an easier way to integrate Nostr with an existing package, possible new Nostr integrations will increase significantly.

I'm applying for a grant to cover development for nostr-php for one year.

Objective: develop and maintain a PHP helper library and distribute this as a package for PHP developers.

> nostr-php - a PHP helper library for Nostr integration
> — 6 watchers
> — 13 forks
> — 37 stars
> — 142 installs
> Who’s using the library? See REFERENCES.md.

Early 2023 the library was built by Kristof (Swentel) who is also a Drupal developer like me. We didn’t know each other before then, but we got in touch while we were both working on a Drupal contrib module for Nostr. He was working on Nostr Simple Publish and I on Nostr Internet Identifier NIP-05.
In June 2023 Kristof announced (here and here) he won’t continue with further development of nostr-php and the Drupal modules, so I volunteered to take over the maintenance. At this moment I'm the only active maintainer.

Deliverables / roadmap

  • See roadmap in Github repository.
  • Demo (SPA) environment built with Symfony & Turbo using the nostr-php library.
  • Weekly reports on nostrver.se (Markdown formatted blog, built with Drupal)

In these reports I'll share the achievements of last week and a plan with actions to work on in the coming week. When this content is created on the site, also events kind 1 and 30023 will be published to the Nostr network for generating exposure.

  • Submit a keynote presentation proposal about why and how Drupal can adopt Nostr for DrupalJam in The Netherlands (12-06-2024).

Built for who?

→ PHP (framework) developers

Developers working with Symfony, Laravel, Zend, Yii, CodeIgniter, CakePHP, WordPress, ReactPHP, Drupal, TYPO3, CraftCMS, BackdropCMS, Grav, Magento, NextCloud and many other less known PHP powered frameworks and systems. They can use the nostr-php library in their project to integrate Nostr.

→ PHP powered platforms

What are the current PHP powered platforms nowadays which are likely to replace their closed social layer with an open networking protocol?

Looking forward: Nostr empowered Drupal initiative

While developing the nostr-php library, I’m also developing Nostr contrib modules to build Nostr embedded Drupal applications. After the initial development phase of nostr-php, this will be the way I’m heading in further developing new and existing Nostr contrib modules for Drupal.

> 💡 What I’m currently building for Drupal?
> → Module which enables to publish long-form content from your Drupal website
> → Module which enables to publish short text notes from your Drupal website
> → Module to register / authorize your Nostr account with a user entity on a Drupal website
> → Module to manage Nostr internet identifiers with user entities on a Drupal website

On these links you can read a concept for a grant submission for a Nostr empowered Drupal / PHP initiative and further thoughts how to integrate Nostr into Drupal:

→ Nostr empowered PHP Drupal initiative

→ 📝 How could Drupal adopt Nostr?

The team

Sebastian Hagens 🇳🇱
I am Sebastian Hagens (1986) living and working in The Netherlands as a fullstack webdeveloper and tech consultant. Father of two little daughters. Working 4 days in a week, self-employed (independent developer) from a small office in an old monastery. I have a set of loyal clients but I also work as a freelancer from time to time. I started to build websites in 1999 with HTML, CSS, JavaScript and PHP.

In 2010 I graduated with a bachelor of design at St.Joost School of Arts and Design with a digital project “root:\ a digital lifeline” around reclaiming your social media data and content.

In 2014 I started to work with Drupal and this tool became my most favorite tool for building solutions for ambitious and complex goals. It feels like a Swiss knife for building many types of web-based solutions.

I would love to see more contributors on the project, so there are some places where we can gather and discuss topics:

Other Nostr stuff and projects

These are some other project I'm working on as well, which are Nostr related in someway.

More contributions can be found on https://nostrver.se.

Sebastian Hagens
📨 info@sebastix.nl
☎️ +31 6 41712778

This content is also published on https://sebastix.notion.site/OpenSats-application-for-Nostr-helper-library-for-PHP-8fb6bd7ac4214fbaaa397b8671170160

Tags
Subscribe to Nostr-PHP