Object-oriented PHP 8 library for Gemini / Gemtext operations
Find a file
2024-07-08 05:50:45 +03:00
src fix multiline code expression 2024-07-07 02:56:24 +03:00
tests/data update document example 2024-06-24 21:57:24 +03:00
.gitignore init composer 2024-06-23 14:52:15 +03:00
composer.json update keywords 2024-06-23 19:17:48 +03:00
LICENSE Initial commit 2024-06-23 14:38:13 +03:00
README.md update readme 2024-07-08 05:50:45 +03:00

gemtext-php

Lightweight, object-oriented PHP 8 library for Gemtext

See also

  • gemini-php - PHP 8 Client library for Gemini connections

Integrations

  • gemini-dl - CLI batch downloader for Gemini protocol
  • Yoda - PHP-GTK Browser for Gemini protocol

Install

composer require yggverse/gemtext

Example

Parse existing document

// Load document from file
$document = new \Yggverse\Gemtext\Document(
    file_get_contents(
        'tests/data/document.gmi'
    )
);

// Get links
foreach ($document->getLinks() as $link)
{
    print(
        $link->toString()
    );
}

Create new document

// Init new document
$document = new \Yggverse\Gemtext\Document;

// Append header
$document->append(
    new \Yggverse\Gemtext\Entity\Header(
        'Hello world'
    )
);

// Init new link
$link = new \Yggverse\Gemtext\Entity\Link(
    'gemini://geminiprotocol.net',
    'The Gemini Program',
    '1965-01-19'
);

// Change link date
$link->setDate(
    date('Y-m-d')
);

// Append link
$document->append(
    $link
);

// Get gemtext
print(
    $document->toString()
);

// Save to file
file_put_contents(
    '/path/to/file.gmi',
    $document->toString()
)