diff --git a/module/Common/README.md b/module/Common/README.md index 3b903f41..0804f249 100644 --- a/module/Common/README.md +++ b/module/Common/README.md @@ -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 + [ + 'headers_to_inspect' => [ + 'CF-Connecting-IP', + 'True-Client-IP', + 'X-Real-IP', + 'Forwarded', + 'X-Forwarded-For', + 'X-Forwarded', + 'X-Cluster-Client-Ip', + 'Client-Ip', + ], + ], + + ]; + ``` diff --git a/module/Common/src/Middleware/LocaleMiddleware.php b/module/Common/src/Middleware/LocaleMiddleware.php index 39cde1c4..12ba084b 100644 --- a/module/Common/src/Middleware/LocaleMiddleware.php +++ b/module/Common/src/Middleware/LocaleMiddleware.php @@ -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. diff --git a/module/IpGeolocation/README.md b/module/IpGeolocation/README.md index feed5025..a3d02cf1 100644 --- a/module/IpGeolocation/README.md +++ b/module/IpGeolocation/README.md @@ -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