mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-17 15:59:56 +03:00
Improved README files
This commit is contained in:
parent
0323e0d17d
commit
15bd839940
3 changed files with 64 additions and 7 deletions
|
@ -4,14 +4,21 @@ This library provides some utils and conventions for web apps. It's main purpose
|
|||
|
||||
Most of the elements it provides require a [PSR-11] container, and it's easy to integrate on [expressive] applications thanks to the `ConfigProvider` it includes.
|
||||
|
||||
## Install
|
||||
|
||||
Install this library using composer
|
||||
|
||||
composer require shlinkio/shlink-common
|
||||
|
||||
> This library is also an expressive module which provides its own `ConfigProvider`. Add it to your configuration to get everything automatically set up.
|
||||
|
||||
## Cache
|
||||
|
||||
A [doctrine cache] adapter is registered, which returns different instances depending on your configuration:
|
||||
|
||||
* An `ArrayCache` instance when the `debug` config is set to true.
|
||||
* A `PredisCache` instance when the `cache.redis` config is defined.
|
||||
* An `ArrayCache` instance when no `cache.redis` is defined and the APCu extension is not installed.
|
||||
* An `ArrayCache` instance when the `debug` config is set to true or when the APUc extension is not installed and the `cache.redis` config is not defined.
|
||||
* An `ApcuCache`instance when no `cache.redis` is defined and the APCu extension is installed.
|
||||
* A `PredisCache` instance when the `cache.redis` config is defined.
|
||||
|
||||
Any of the adapters will use the namespace defined in `cache.namespace` config entry.
|
||||
|
||||
|
@ -38,3 +45,45 @@ return [
|
|||
```
|
||||
|
||||
When the `cache.redis` config is provided, a set of servers is expected. If only one server is provided, this library will treat it as a regular server, but if several servers are defined, it will treat them as a redis cluster and expect the servers to be configured as such.
|
||||
|
||||
## Middlewares
|
||||
|
||||
This module provides a set of useful middlewares, all registered as services in the container:
|
||||
|
||||
* **CloseDatabaseConnectionMiddleware**:
|
||||
|
||||
Should be an early middleware in the pipeline. It makes use of the EntityManager that ensure the database connection is closed at the end of the request.
|
||||
|
||||
It should be used when serving an app with a non-blocking IO server (like Swoole or ReactPHP), which persist services between requests.
|
||||
|
||||
* **LocaleMiddleware**:
|
||||
|
||||
Sets the locale in the translator, based on the `Accapt-Language` header.
|
||||
|
||||
* **IpAddress** (from [akrabat/ip-address-middleware] package):
|
||||
|
||||
Improves detection of the remote IP address.
|
||||
|
||||
The set of headers which are inspected in order to search for the address can be customized using this configuration:
|
||||
|
||||
```php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
|
||||
'ip_address_resolution' => [
|
||||
'headers_to_inspect' => [
|
||||
'CF-Connecting-IP',
|
||||
'True-Client-IP',
|
||||
'X-Real-IP',
|
||||
'Forwarded',
|
||||
'X-Forwarded-For',
|
||||
'X-Forwarded',
|
||||
'X-Cluster-Client-Ip',
|
||||
'Client-Ip',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
```
|
||||
|
|
|
@ -24,8 +24,6 @@ class LocaleMiddleware implements MiddlewareInterface
|
|||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Process an incoming server request and return a response, optionally delegating
|
||||
* to the next middleware component to create the response.
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
# IP Address Geolocation module
|
||||
# Shlink IP Address Geolocation module
|
||||
|
||||
Shlink module with tools to locate an IP address suing different strategies.
|
||||
Shlink module with tools to geolocate an IP address using different strategies.
|
||||
|
||||
## Install
|
||||
|
||||
Install this library using composer
|
||||
|
||||
composer require shlinkio/shlink-ip-geolocation
|
||||
|
||||
> This library is also an expressive module which provides its own `ConfigProvider`. Add it to your configuration to get everything automatically set up.
|
||||
|
||||
## *TODO*
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
|
Loading…
Add table
Reference in a new issue