@ -14,12 +14,39 @@ PHP interface for Gemini protocol queries by TLS socket connection
@@ -14,12 +14,39 @@ PHP interface for Gemini protocol queries by TLS socket connection
### Request
```
``` php
$request = new \Yggverse\Gemini\Client\Request(
'gemini://betahowto.duckdns.org:1965/archive'
);
```
**Resolved request (SNI)**
Optionally, provide resolved IP as the second argument
``` php
$request = new \Yggverse\Gemini\Client\Request(
'gemini://betahowto.duckdns.org:1965/archive' // target URL
'94.140.114.89' // resolved IP, skip to use system-wide resolver
);
```
Alternatively, use `setResolvedHost` method of `Request` object before `getResponse`
#### Request::getResolvedHost
``` php
$request->setResolvedHost(
'94.140.114.89'
)
```
* to resolve address with PHP, take a look on the [net-php ](https://github.com/YGGverse/net-php ) library!
#### Request::setResolvedHost
Get resolved host back
#### Request::setHost
#### Request::getHost
#### Request::setPort
@ -32,7 +59,7 @@ $request = new \Yggverse\Gemini\Client\Request(
@@ -32,7 +59,7 @@ $request = new \Yggverse\Gemini\Client\Request(
Execute requested URL and return raw response
```
``` php
var_dump(
$request->getResponse()
);
@ -42,7 +69,7 @@ var_dump(
@@ -42,7 +69,7 @@ var_dump(
This class provides additional features for the raw response operations
```
``` php
$response = new \Yggverse\Gemini\Client\Response(
$request->getResponse()
);
@ -55,7 +82,7 @@ $response = new \Yggverse\Gemini\Client\Response(
@@ -55,7 +82,7 @@ $response = new \Yggverse\Gemini\Client\Response(
#### Response::setBody
#### Response::getBody
```
``` php
var_dump(
$response->getBody()
);
@ -69,7 +96,7 @@ Object-oriented API for Gemtext
@@ -69,7 +96,7 @@ Object-oriented API for Gemtext
Basic methods to work with `text/gemini` documents
```
``` php
$body = new \Yggverse\Gemini\Gemtext\Body(
$response->getBody() // gemtext body from client response or .gmi file
);
@ -80,7 +107,7 @@ $body = new \Yggverse\Gemini\Gemtext\Body(
@@ -80,7 +107,7 @@ $body = new \Yggverse\Gemini\Gemtext\Body(
#### Body::getH3
#### Body::getLinks
```
``` php
var_dump(
$body->getLinks() // returns array of inline links
);
@ -90,7 +117,7 @@ var_dump(
@@ -90,7 +117,7 @@ var_dump(
Find context links by protocol as argument, `gemini` by default
```
``` php
var_dump(
$body->findLinks('http') // returns array of http links found
);
@ -100,7 +127,7 @@ var_dump(
@@ -100,7 +127,7 @@ var_dump(
Strip gemini tags from Gemini document
```
``` php
var_dump(
$body->skipTags() // strip all tags
);
@ -121,7 +148,7 @@ Inline links parser.
@@ -121,7 +148,7 @@ Inline links parser.
Allows to extract address, date with timestamp and alt text from link line given
```
``` php
foreach ($body->getLinks() as $line)
{
$link = new \Yggverse\Gemini\Gemtext\Link(
@ -143,7 +170,7 @@ foreach ($body->getLinks() as $line)
@@ -143,7 +170,7 @@ foreach ($body->getLinks() as $line)
This method also validates time format and returns the unix timestamp as linked argument
```
``` php
var_dump(
$link->getDate(
$timestamp // get unix time from this variable
@ -171,7 +198,7 @@ Allows to simple deploy new apps or make existing website mirror
@@ -171,7 +198,7 @@ Allows to simple deploy new apps or make existing website mirror
Read DokuWiki and convert to Gemini
```
``` php
$reader = new \Yggverse\Gemini\Dokuwiki\Reader(
// optional regex rule set array
);
@ -184,7 +211,7 @@ $reader = new \Yggverse\Gemini\Dokuwiki\Reader(
@@ -184,7 +211,7 @@ $reader = new \Yggverse\Gemini\Dokuwiki\Reader(
Get or change existing regex rule (or just skip by using build-in set)
```
``` php
echo $reader->setRule(
'/subject/ui',
'replacement'
@ -196,7 +223,7 @@ echo $reader->setRule(
@@ -196,7 +223,7 @@ echo $reader->setRule(
#### Reader::getMacros
#### Reader::setMacros
```
``` php
echo $reader->setMacros(
'~my-macros-key~',
'~my-macros-value~',
@ -211,7 +238,7 @@ As wiki has lot of inline links, to make converted document well-readable, this
@@ -211,7 +238,7 @@ As wiki has lot of inline links, to make converted document well-readable, this
If you don't like this implementation, feel free to change it by `Reader::setRule` method!
```
``` php
echo $reader->toGemini(
file_get_contents(
'/host/data/pages/index.txt'
@ -223,7 +250,7 @@ echo $reader->toGemini(
@@ -223,7 +250,7 @@ echo $reader->toGemini(
Get document title
```
``` php
$gemini = $reader->toGemini(
file_get_contents(
'/host/data/pages/index.txt'
@ -239,7 +266,7 @@ echo $reader->getH1(
@@ -239,7 +266,7 @@ echo $reader->getH1(
Get document links
```
``` php
$gemini = $reader->toGemini(
file_get_contents(
'/host/data/pages/index.txt'
@ -255,7 +282,7 @@ echo $reader->getLinks(
@@ -255,7 +282,7 @@ echo $reader->getLinks(
Provides methods for simple and secure interaction with DokuWiki file storage
```
``` php
$filesystem = new \Yggverse\Gemini\Dokuwiki\Filesystem(
'/host/data' // storage location
);
@ -265,7 +292,7 @@ $filesystem = new \Yggverse\Gemini\Dokuwiki\Filesystem(
@@ -265,7 +292,7 @@ $filesystem = new \Yggverse\Gemini\Dokuwiki\Filesystem(
Return simple array of all files in storage
```
``` php
var_dump (
$filesystem->getList(
'hello:world'
@ -277,7 +304,7 @@ var_dump (
@@ -277,7 +304,7 @@ var_dump (
Return all files under the storage folder in tree format
```
``` php
var_dump (
$filesystem->getTree(
'hello:world'
@ -289,7 +316,7 @@ var_dump (
@@ -289,7 +316,7 @@ var_dump (
Return pages under the given data directory
```
``` php
var_dump (
$filesystem->getPagePathsByPath(
// absolute path to target data directory (e.g. Filesystem::getDirectoryPathByUri)
@ -302,7 +329,7 @@ var_dump (
@@ -302,7 +329,7 @@ var_dump (
Return absolute path to stored page file
```
``` php
var_dump (
$filesystem->getPagePathByUri(
'hello:world'
@ -315,7 +342,7 @@ var_dump (
@@ -315,7 +342,7 @@ var_dump (
Return page URI in `dokuwiki:format`
```
``` php
var_dump (
$filesystem->getPageUriByPath(
'/full/path/to/page.txt'
@ -327,7 +354,7 @@ var_dump (
@@ -327,7 +354,7 @@ var_dump (
Return absolute path to stored media file
```
``` php
var_dump (
$filesystem->getMediaPathByUri(
'hello:world'
@ -339,7 +366,7 @@ var_dump (
@@ -339,7 +366,7 @@ var_dump (
Return file MIME if path match storage item
```
``` php
var_dump (
$filesystem->getMimeByPath(
'/full/path/to/page.txt'
@ -351,7 +378,7 @@ var_dump (
@@ -351,7 +378,7 @@ var_dump (
Return file content if path match storage item
```
``` php
var_dump (
$filesystem->getDataByPath(
'/full/path/to/page.txt'
@ -363,7 +390,7 @@ var_dump (
@@ -363,7 +390,7 @@ var_dump (
Check path exist and match storage item
```
``` php
var_dump (
$filesystem->isPath(
'/full/path/to/page.txt'
@ -375,7 +402,7 @@ var_dump (
@@ -375,7 +402,7 @@ var_dump (
Useful methods to minify controller codebase
```
``` php
$helper = new \Yggverse\Gemini\Dokuwiki\Helper(
new \Yggverse\Gemini\Dokuwiki\Filesystem(),
new \Yggverse\Gemini\Dokuwiki\Reader()
@ -386,7 +413,7 @@ $helper = new \Yggverse\Gemini\Dokuwiki\Helper(
@@ -386,7 +413,7 @@ $helper = new \Yggverse\Gemini\Dokuwiki\Helper(
Return simple array of children section links in Gemini format
```
``` php
var_dump (
$helper->getChildrenSectionLinksByUri(
'hello:world'
@ -398,7 +425,7 @@ var_dump (
@@ -398,7 +425,7 @@ var_dump (
Return simple array of children page links in Gemini format
```
``` php
var_dump (
$helper->getChildrenPageLinksByUri(
'hello:world'
@ -410,7 +437,7 @@ var_dump (
@@ -410,7 +437,7 @@ var_dump (
Return page link (that contain document name) in Gemini format
```
``` php
var_dump (
$helper->getPageLinkByPath(
$filesystem->getPagePathByUri(