PHP 8 Library for Gemini Protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.3 KiB

9 months ago
# gemini-php
9 months ago
7 months ago
PHP 8 Library for [Gemini Protocol](https://geminiprotocol.net)
9 months ago
9 months ago
## Usage
```
composer require yggverse/gemini
```
## Client
PHP interface for Gemini protocol queries by TLS socket connection
### Request
``` php
$request = new \Yggverse\Gemini\Client\Request(
7 months ago
'gemini://yggverse.cities.yesterweb.org:1965/index.gmi'
);
```
**Resolved request (SNI)**
7 months ago
For direct connection provide resolved IP as the second argument
``` php
$request = new \Yggverse\Gemini\Client\Request(
7 months ago
'gemini://yggverse.cities.yesterweb.org:1965/index.gmi' // target URL
'68.133.1.71' // resolved IP, skip to use system-wide resolver
);
```
Alternatively, use `setResolvedHost` method of `Request` object before `getResponse`
7 months ago
#### Request::setResolvedHost
``` php
$request->setResolvedHost(
7 months ago
'68.133.1.71'
)
```
7 months ago
* to resolve network address with PHP, take a look on the [net-php](https://github.com/YGGverse/net-php) library!
7 months ago
#### Request::getResolvedHost
Get resolved host back
#### Request::setHost
#### Request::getHost
#### Request::setPort
#### Request::getPort
#### Request::setPath
#### Request::getPath
#### Request::setQuery
#### Request::getQuery
#### Request::getResponse
Execute requested URL and return raw response
``` php
var_dump(
$request->getResponse()
);
```
7 months ago
#### Request::getOptions
#### Request::setOptions
``` php
$request = new \Yggverse\Gemini\Client\Request(
'gemini://yggverse.cities.yesterweb.org',
'68.133.1.71' // make direct request to the resolved host
);
$request->setOptions(
[
'ssl' =>
[
'peer_name' => 'yggverse.cities.yesterweb.org', // SNI
'verify_peer' => false,
'verify_peer_name' => false
]
]
);
```
### Response
This class provides additional features for the raw response operations
``` php
$response = new \Yggverse\Gemini\Client\Response(
$request->getResponse()
);
```
#### Response::setCode
#### Response::getCode
#### Response::setMeta
#### Response::getMeta
#### Response::setBody
#### Response::getBody
``` php
var_dump(
$response->getBody()
);
9 months ago
```
7 months ago
## Integrations
* [β-Doku is DokuWiki Satellite for Gemini Protocol](https://github.com/YGGverse/bdoku)
7 months ago
* [Yo! Crawler for different networks](https://github.com/YGGverse/Yo/tree/gemini)
7 months ago
* [Yoda - PHP-GTK browser for Gemini Protocol](https://github.com/YGGverse/Yoda)