Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/YGGverse/gemini-php
PHP 8 Library for Gemini Protocol
https://github.com/YGGverse/gemini-php
1965 composer gemini gemini-api gemini-client gemini-library gemini-php gemini-php-api gemini-protocol library socket tls
Last synced: 3 months ago
JSON representation
PHP 8 Library for Gemini Protocol
- Host: GitHub
- URL: https://github.com/YGGverse/gemini-php
- Owner: YGGverse
- License: mit
- Created: 2024-01-30T09:40:28.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-08-02T23:17:29.000Z (3 months ago)
- Last Synced: 2024-08-02T23:48:26.559Z (3 months ago)
- Topics: 1965, composer, gemini, gemini-api, gemini-client, gemini-library, gemini-php, gemini-php-api, gemini-protocol, library, socket, tls
- Language: PHP
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gemini - gemini-php - Composer library for Gemini - includes DokuWiki converter, file-system operations and other API (Tools / Gemtext converters)
README
# gemini-php
PHP 8 Library for [Gemini Protocol](https://geminiprotocol.net)
_For optimization reasons, some experimental features like `Dokuwiki` and `GTK3/Pango` was dropped from `1.0.0` release, but available in [previous versions](https://github.com/YGGverse/gemini-php/releases/tag/0.10.1). `Gemtext` component re-implemented as separated library (see [Extras](#extras))_
## Extras
* [gemtext-php](https://github.com/YGGverse/gemtext-php) - Object-oriented PHP 8 library for Gemini / Gemtext operations
## Usage
```
composer require yggverse/gemini
```## Client
PHP interface for Gemini protocol queries by TLS socket connection
### Request
``` php
$request = new \Yggverse\Gemini\Client\Request(
'gemini://yggverse.cities.yesterweb.org:1965/index.gmi'
);
```**Resolved request (SNI)**
For direct connection provide resolved IP as the second argument
``` php
$request = new \Yggverse\Gemini\Client\Request(
'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`
#### Request::setResolvedHost
``` php
$request->setResolvedHost(
'68.133.1.71'
)
```* to resolve network address with PHP, take a look on the [net-php](https://github.com/YGGverse/net-php) library!
#### Request::getResolvedHost
Get resolved host back
#### Request::setHost
#### Request::getHost
#### Request::setPort
#### Request::getPort
#### Request::setPath
#### Request::getPath
#### Request::setQuery
#### Request::getQuery
#### Request::getResponseExecute requested URL and return raw response
``` php
var_dump(
$request->getResponse()
);
```#### 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()
);
```## Integrations
* [gemini-dl](https://github.com/YGGverse/gemini-dl) - CLI Batch downloader for Gemini Protocol
* [Yo!](https://github.com/YGGverse/Yo/tree/gemini) - Crawler for different networks
* [Yoda](https://github.com/YGGverse/Yoda) - PHP-GTK browser for Gemini Protocol
* [β-Doku](https://github.com/YGGverse/bdoku) - DokuWiki Satellite for Gemini Protocol