PHP

#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

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 

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 PHP