mirror of
https://github.com/YGGverse/yggverse.github.io.git
synced 2026-03-31 17:15:36 +00:00
add gemini-dl, gemtext-php resources
This commit is contained in:
parent
a19369a4c5
commit
ea59f4dc84
4 changed files with 173 additions and 2 deletions
78
gemini/gemtext-php/index.gmi
Executable file
78
gemini/gemtext-php/index.gmi
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
# gemtext-php
|
||||
|
||||
PHP 8 / Composer Library for Gemtext Operations
|
||||
|
||||
This library is lightweight, object-oriented Gemtext replacement to gemini-php
|
||||
|
||||
## Install
|
||||
|
||||
``` bash
|
||||
composer require yggverse/gemtext:dev-main
|
||||
```
|
||||
|
||||
## 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()
|
||||
)
|
||||
```
|
||||
|
||||
## Download
|
||||
|
||||
=> https://github.com/YGGverse/gemtext-php GitHub
|
||||
Loading…
Add table
Add a link
Reference in a new issue