Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yggverse/gemtext-php
Object-oriented PHP 8 library for Gemini / Gemtext operations
https://github.com/yggverse/gemtext-php
composer gemini gemini-php gemini-protocol gemtext gemtext-php library parser php text-gemini
Last synced: 28 days ago
JSON representation
Object-oriented PHP 8 library for Gemini / Gemtext operations
- Host: GitHub
- URL: https://github.com/yggverse/gemtext-php
- Owner: YGGverse
- License: mit
- Created: 2024-06-23T11:38:13.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-08T02:54:45.000Z (4 months ago)
- Last Synced: 2024-10-10T03:05:21.547Z (28 days ago)
- Topics: composer, gemini, gemini-php, gemini-protocol, gemtext, gemtext-php, library, parser, php, text-gemini
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gemtext-php
Lightweight, object-oriented PHP 8 library for [Gemtext](https://geminiprotocol.net/docs/gemtext.gmi) markup
## See also
* [gemini-php](https://github.com/YGGverse/gemini-php) - PHP 8 Client library for Gemini protocol connections
## Integrations
* [gemini-dl](https://github.com/YGGverse/gemini-dl) - CLI batch downloader for Gemini protocol
* [Yoda](https://github.com/YGGverse/Yoda) - PHP-GTK Browser for Gemini protocol## Install
``` bash
composer require yggverse/gemtext
```## Example
### Parse existing document
``` php
// 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
``` php
// 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()
)
```