shlink/module/Common
2019-08-10 23:26:39 +02:00
..
config Moved all ip-geolocation related stuff to its own module 2019-08-10 13:43:52 +02:00
functions Created function to abstract how to load config from a glob pattern 2019-08-10 14:09:42 +02:00
src Moved WrongIpException to IpGeolocation module 2019-08-10 23:26:39 +02:00
test Moved WrongIpException to IpGeolocation module 2019-08-10 23:26:39 +02:00
test-db Defined config to run database tests against mysql and postgres 2019-03-05 20:36:35 +01:00
README.md Enhanced CacheFactory to support redis and allow optional APCu 2019-08-10 17:44:09 +02:00

Shlink Common

This library provides some utils and conventions for web apps. It's main purpose is to be used on Shlink project, but any PHP project can take advantage.

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.

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 ApcuCacheinstance when no cache.redis is defined and the APCu extension is installed.

Any of the adapters will use the namespace defined in cache.namespace config entry.

<?php
declare(strict_types=1);

return [

   'debug' => false,

   'cache' => [
       'namespace' => 'my_namespace',
       'redis' => [
           'servers' => [
               'tcp://1.1.1.1:6379',
               'tcp://2.2.2.2:6379',
               'tcp://3.3.3.3:6379',
           ],
       ],
   ],

];

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.