Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PHP x Nostr
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hakkadaikon
November 21, 2024
Programming
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHP x Nostr
第170回 PHP勉強会@東京で発表した内容
https://phpstudy.connpass.com/event/335943/
Hakkadaikon
November 21, 2024
Transcript
28 slides
イラスト: @Bitpopart https://nostr-php.dev
自己紹介
名前 : 発火大根 PHP歴 : 3-4年くらい PHP勉強会 : offで1回参加したことあり 自己紹介1
自己紹介2 ~直近の活動~ 2024/9/23, Nostrの国際カンファレンスの 発起人をやりました。 (参加者99人、海外から参加/登壇多数) 登壇したり Nostrを提唱したfiatjaf氏に メッセージ貰ったり マグロの
解体ショーも!
Q.Nostrとは?
A.プロトコルです
Twitter(X)ぽいSNSとか Damus Nostter
クックパッド みたいなサービスとか zap.cooking
NoteやQiitaみたいな エントリ投稿できるやつとか YakiHonne
色々作れます
①WebSocket通信で速い ②電話番号メールアドレスいらない ③潰れない Nostrの特徴
①WebSocket通信で速い Nostr Websocket TCP / IP Ethernet Physical パケット クライアント
リレー (サーバー)
②電話番号メールアドレスいらない { "content": "test", “created_at”: 1726456407, "id": "7b31d7a9d9e8f65b1e3102a4cdc...", "kind": 1,
"pubkey": "101b30ee88c27a13de68bf7...", "sig": "3d7d019db85deece5c1d704c987393957bb8c5c61458...", "tags": [] } ・アカウント=鍵(公開鍵/秘密鍵) ・全てのイベント発行時に電子署名する
③潰れない ・自分で選んだ複数のリレーにデータをバラまく
今年から、他の界隈 x Nostrの組み合わせで 何回かLTをやっています 2024/2/10 Nostr x Vim 2024/4/27 Nostr
x C# 2024/10/27 Nostr x Emacs 2024/11/21 Nostr x PHP <- 今日
PHPでも Nostr開発 してみよう
使うOSS (PHP製のNostrプロトコルスタック) 8.1以上で動くよ
STEP1. laravelのプロジェクトを作る $composer create-project --prefer-dist laravel/laravel nostr-console
STEP2. nostr-phpをインストール $ composer require swentel/nostr-php
STEP3. artisanコマンドを作る $ php artisan make:command FetchTimelineCommand
STEP4. ちょろっと ソース書く(38L) <?php namespace App¥Console¥Commands; use Illuminate¥Console¥Command; use swentel¥nostr¥Filter¥Filter;
use swentel¥nostr¥Message¥RequestMessage; use swentel¥nostr¥Relay¥Relay; use swentel¥nostr¥Request¥Request; use swentel¥nostr¥Subscription¥Subscription; class FetchTimelineCommand extends Command { protected $signature = 'app:fetch-timeline-command {--kinds=1} {--limit=1}'; protected $description = 'Fetch the nostr timeline'; public function handle() { $kinds = array_map('intval', explode(',', $this->option('kinds'))); $limit = intval($this->option('limit')); $subid = (new Subscription())->setId(); $filter = (new Filter())->setKinds($kinds)->setLimit($limit); $response = ( new Request( new Relay('wss://yabu.me'), new RequestMessage($subid, [$filter]) ) )->send(); echo sprintf("%s¥n", json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); return 0; } }
NostrのTLを取得する コンソールアプリが 出来ました
早速動かしてみよう! $ php artisan app:fetch-timeline-command --kinds=1 --limit=1 --kinds : イベント種別
(0:プロフィール 1:投稿 7:リアクション etc…) --limit : イベント取得件数
{ "wss://yabu.me": [ { "type": "EVENT", "isSuccess": true, "message": "",
"subscriptionId": "Wd2SDCfvkh9T0eO6I1Mgw85iJbqGURLtjEr7BKmAyPasZNXHo4cFYuQ3lzxpnV", "event": { "content": "てすと", "created_at": 1732172057, "id": "de20ad56d21cf4c2e1fae1c67a58dbe475120fecded61c4563ed1faeff7b9839", "kind": 1, "pubkey": "101b30ee88c27a13de68bf7c8c06368ea3e3e837641595c18675677d18a46a45", "sig": "4d7002e71853282e61cb97ff0e093457d3dfd5c99fd512b1e074aaaca1a50a84250b3d16f6b895b7ebf0c8df1f247aee1cd0569f7075f937ed5e8ddf5bd0f36d", "tags": [] } }, { "type": "EOSE", "isSuccess": true, "message": "", "subscriptionId": "Wd2SDCfvkh9T0eO6I1Mgw85iJbqGURLtjEr7BKmAyPasZNXHo4cFYuQ3lzxpnV" } ] } こういうjsonが取れます
結構カンタンに つくれる
awesome- nostr-japan
気軽にやってみよう!仕組みはシンプル
Thank you for your attention !
More Decks by Hakkadaikon
See All by Hakkadaikon
高橋メソッドでCVE解説シリーズ 〜CVE-2026-123633/CVE-2026-123007〜
hakkadaikon
0
36
高橋メソッドでCVE解説シリーズ 〜CVE-2026-99999〜
hakkadaikon
0
45
高橋メソッドでCVE解説シリーズ 〜CVE-2026-98432〜
hakkadaikon
0
41
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
280
MoQTフルスクラッチ実装
hakkadaikon
1
130
Just do it ! で 走り抜けてきたけど ちょっと立ち止まってみた
hakkadaikon
0
960
自作WebSocket (RFC6455)
hakkadaikon
0
190
routstrについて
hakkadaikon
0
190
Nostr x BTC
hakkadaikon
0
88
Other Decks in Programming
See All in Programming
眠らない開発チームの作り方
biwakonbu
0
180
Canvas 2D Context Next
petamoriken
0
860
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
450
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
120
祈るテストから、探索するテストへ 〜Lincheckではじめる並行処理テスト〜
yyh_gl
0
440
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
1.3k
コード生成時代のAPI定義を支えるRequest Spec移行
pvcresin
0
320
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
470
Stage 3でも仕様は変わる。アプリケーション開発者のためのTC39プロセスの読み方
bicstone
1
1.2k
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
250
ruby/uri meets WHATWG
jinroq
0
180
Compiling Your Language to WasmGC & Friends
tanishiking
0
880
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
4
660
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
Optimizing for Happiness
mojombo
378
72k
HDC tutorial
michielstock
2
1k
Utilizing Notion as your number one productivity tool
mfonobong
4
710
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
[SF Ruby Conf 2025] Rails X
palkan
3
1.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k