PHP

Nostr empowered Drupal initiative

Problem

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 web sites 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.

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

Most content is always centralised

When content is published on a Drupal powered platform, it usually only exists on that website. With good Nostr integration the goal is to syndicate this content elsewhere on the Nostr network. This is called Publish (on your) Own Site, Syndicate Elsewhere (POSSE - source: https://indieweb.org/POSSE) aka cross-posting.

Distributing content across platforms is hard

Drupal site owners are limited to web APIs to distribute content across different platforms, which comes with downsides such as complex access key distribution. With Nostr we don't need such complex APIs because interoperability is integrated on protocol level. This means we don't need permission to distribute content which can be read by any client.

Like Nostr, Drupal is able to handle many different types of content thanks to the famous flexible fieldable entity model. When we combine features of Nostr to distribute the content made in Drupal, we will enter a new era of content publishing on the web.

This initiative

Why should we integrate Nostr in Drupal? Drupal is a prime example of the traditional web. To let the adoption of Nostr grow, it needs to be integrated into the web as it exists today.

We can use Drupal as a tool for achieving this.

Also Drupal is always looking for new ways to accelerate with new technology, so I’m convinced also the Drupal community will welcome Nostr with an open mindset.

This initiative will also benefit other similar FOSS CMS tools such as WordPress, Joomla, TYPO3 or BackdropCMS by building a general PHP library package for Nostr integration.

What have Drupal and Nostr in common?

Both have a strong critical community and are open source champions.

“Come for the software, stay for the community”, a popular meme within the Drupal community. Drupal has a steep learning curve, but with the help of others it’s more fun and easier to master it. At this moment, Nostr has also a steep learning curve with a lot of new features which requires a new conceptual thinking model. The Nostr community is there to help you understand the ecosystem.

The open web manifesto of Drupal



Source: Driesnote at DrupalCon Lille 2023

> The open web is more than a technology — it’s a cause.

💡 In case you've missed it: Dries (founder and project lead of Drupal) is a fan of Nostr!

Read his article Nostr, love at first sight

Freedom tech

Drupal is FOSS and freedom tech. Free from subscriptions, free from proprietary software dependencies, free to customize and modify, and free with your own terms and conditions on how you would like to use Drupal.

Future of Drupal

When Drupal 7 was updated to Drupal 8, the community adopted the Symfony PHP framework as the basis for Drupal core. While this opened up new and powerful opportunities for integrations, it steepened the learning curve for both developers and site builders.

Now, with Drupal at version 10, it's faster and easy-to-use than ever. But there’s still work to be done to improve the developer and site-builder experience.

This will take time, but there are several strategic (core) and community initiatives which are giving a future insight where Drupal is heading:

  • Marketing

    For the first time in history, there is a dedicated initiative for promoting Drupal on the market. Their first presence was on the Web Summit 2023 (https://dri.es/drupal-at-web-summit).
  • Automated updates

    Updating Drupal is time consuming and sometimes quite hard. While WordPress has automated this already for many years, Drupal is far behind this. This feature will make Drupal much easier to maintain. It will reduce the barrier to start Drupal as well without the hassle about maintaining it.
  • Project browser for more easy-to-install modules

    Drupal has to become more user-friendly and easier to understand as a low-code solution for building websites. This initiative is part of that objective.
  • Distributions and recipes

    Because Drupal is so flexible, you can build almost anything. But it’s hard knowing where to start. The real magic often happens when you start using contrib modules and know how to configure them. WIth distributions / recipes it will be easier to kickstart your project with pre-installed modules and configurations.
  • API client

    Use this JavaScript utility in your JavaScript application to connect to the JSON:API of your Drupal website.
  • Single Directory Components

    Familiar approach for building frontend components for Javascript framework developers (React, Svelte, Vue)

The future of Drupal is bright and optimistic. Drupal is expected to expand from an enterprise solution to also an easy-to-use content managing tool. More tools to make it easier to start, build and maintain Drupal will be included in core in time. In addition, front-end / theme development is catching up with popular Javascript development frameworks.

Deliverables / roadmap

I'm applying for a grant to cover development for one year. These are the three main objectives for building an application with PHP and Drupal:

  1. Develop and maintain a generalised Nostr helper library for PHP and distribute it as a PHP package for PHP developers
  2. Suite of contributed Drupal modules to provide rich Nostr integration
  3. Drupal recipe / distribution to provide Nostr best practices for content creators and site builders, using the aforementioned contributed modules

Nostr helper library for PHP

See OpenSats application for Nostr helper library for PHP

This package will be a dependency of every Nostr contrib module for Drupal. Because the library is project agnostic, it can be used by any PHP powered application.

  • Github: nostr-php - see roadmap and at this moment I'm the only active maintainer

> 💡 Inspired by the work of Swentel (who started to build nostr-php)

> In 2019 Swentel (Kristof) build several Drupal contrib modules for integrating ActivityPub and some IndieWeb standards. His work was partly funded with a NGI grant by NLnet foundation (source).

>

> * https://realize.be/blog/personal-reader-drupal

> * https://www.drupal.org/project/reader

> * IndieWeb | Drupal.org

> * https://www.drupal.org/project/activitypub

Drupal contributed modules for Nostr integration

  • nostr_auth

    Register / login with your Nostr account. A new user entity will be created with your keys attached. The provided password will be used to encrypt sensitive data. At least one of the following submodules must be activated.

    Submodules:

    • nostr_nsec
    • nostr_nip07
    • nostr_nip46
  • nostr_content_nip23 (in development — alpha release)

    Publish your Markdown formatted content from Drupal to the Nostr network. Republishing (editing) is provided and saving the content as a draft as well.
  • nostr_media

    Provides NIP-94 (and NIP-98) integration for your media entities. With this module you could provide a Nostr media service similar to nostr.build (build with PHP).
  • nostr_id_nip05 (in development — alpha release)

    A module where you can configure the content in the ~/.well-know/nostr.json file.
  • nostr_notes (similar to nostr_simple_publish, in development — alpha release)

    A module providing a feature to publish a short text note (the content is used from a pre-configured textfield of a content type) from the website.
  • nostr_reactions

    A module providing a feature to place a reaction (with a emoticon) below a piece of content.
  • nostr_zap_button

    A module providing a block / button to send a zap to the author of the content.
  • nostr_comments

    A module providing the feature to place comments with your Nostr account on content on your website.
  • nostr_tags

    Drupal provides a solid way of building fieldable taxonomies which can be used as references to other content types. With this module you can map these taxonomies to Nostr tags which will be added to the events you're publishing.
  • zap_to_unlock

    Send a zap to the author to view the full content.
  • nostr_relay

    https://github.com/nostriphant/transpher

    Configure a relay written in PHP. All Drupal entities (content) will be available as Nostr events towards clients and the relay is capable of receiving Nostr events from clients.
  • nostr_embed

    A module where you can embed one or more Nostr events on pages on the website. Embedded Nostr events can be provided with filter arguments (like npubs, kinds, date range, limit and tags).

During development sure new insights and ideas for modules will popup. I’m already working on a list with some other modules which can be build also: [[Nice to have features (modules)]]

Drupal recipe / distribution

This will include all the configuration, a frontend theme and modules to get started with Drupal as a Nostr client.

  • Full user integration with Nostr keys
  • Posting events from the Drupal CMS
  • Support different forms of feedback (Nostr reaction events) on content
  • Full media support with NIP-94 and NIP-98 integration so Drupal can be used as a file hosting server for Nostr clients to make file sharing interoperable.

    The baseline for the distribution with these (yet to be build) contrib modules mentioned in the previous section.

Marketing

Weekly reports

On https://nostrver.se (will be built with Drupal) weekly reports (a blog) will be published. In each report 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 with kind 1 and 30023 will be published for generating exposure.

Drupal community initiative

One of the objectives is to get this initiative listed as a community initiative for generating exposure. I will send a proposal as documented here.

If approved, it will be listed on several places, including:

Built for who?

Online content creators and publishers who care about content ownership and their self-owned social graph

Content creators should use something they own by themselves. They should store their content they create on a safe, self-owned place which can be accessible by their own terms and conditions.

Business owners who're building a Nostr business

With Drupal they can build the website they need with Nostr integrated.

Communities

Community builders looking for a tool to build their community on their self-owned digital land.

Drupal site builders & developers

Large organizations who need to syndicate their content across multiple websites

PHP framework developers

Developers working with Symfony / Laravel / WordPress / BackdropCMS / NextCloud. They can use the nostr-php library in their project to integrate Nostr.

Some potential cases for a Nostr powered Drupal website:

  • NostReport

    They could publish / crosspost a report as a note and/or as a Markdown formatted piece of content from the Drupal site. The website will be used mainly as an archive for all published content.
  • BitcoinBrabant webshop (with Drupal Commerce)

    See this thread where Bert shares his wish to save as least customer data as possible.

    A Nostr account can be used in the checkout process to achieve this.

We need more developers for this initiative, so there are some places where we can gather and contribute:

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

Week 38 updates

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

Subscribe to PHP