PHPackages                             shlinkio/shlink-common - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shlinkio/shlink-common

ActiveProject[Utility &amp; Helpers](/categories/utility)

shlinkio/shlink-common
======================

Common tools used by Shlink

v8.1.0(2mo ago)263.8k↓12.8%3[1 issues](https://github.com/shlinkio/shlink-common/issues)1MITPHPPHP ^8.4CI passing

Since Aug 12Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/shlinkio/shlink-common)[ Packagist](https://packagist.org/packages/shlinkio/shlink-common)[ Docs](https://shlink.io)[ RSS](/packages/shlinkio-shlink-common/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (64)Versions (54)Used By (1)

Shlink Common
=============

[](#shlink-common)

[![Build Status](https://camo.githubusercontent.com/73408f956594576ab0d2e2fbe89aff93902dbd50f5ab960731c8047e94af0b85/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73686c696e6b696f2f73686c696e6b2d636f6d6d6f6e2f63692e796d6c3f6272616e63683d6d61696e266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/shlinkio/shlink-common/actions/workflows/ci.yml?query=workflow%3A%22Continuous+integration%22)[![Code Coverage](https://camo.githubusercontent.com/df330e63dfb16678017b83e2149fc6ee59b7c66cd81162f5aa6a821507a17a43/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f73686c696e6b696f2f73686c696e6b2d636f6d6d6f6e2f6d61696e3f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/shlinkio/shlink-common)[![Latest Stable Version](https://camo.githubusercontent.com/87a5893028d65cf2f0019fe086beb27cd8283d4b3976f65791fb0ce5e2b7abfb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73686c696e6b696f2f73686c696e6b2d636f6d6d6f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shlinkio/shlink-common)[![License](https://camo.githubusercontent.com/1be4900e603f381e6acac49e720bfcbdcd6903736102658f4d256cafe1b898b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73686c696e6b696f2f73686c696e6b2d636f6d6d6f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/shlinkio/shlink-common/blob/main/LICENSE)[![Paypal donate](https://camo.githubusercontent.com/f7bd7ab1d7bea7a4ac78f5189c56ce2dbf8cc73608863e0dd9408e10ddca4673/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d70617970616c2d626c75652e7376673f7374796c653d666c61742d737175617265266c6f676f3d70617970616c26636f6c6f72413d616161616161)](https://slnk.to/donate)

This library provides some utils and conventions for web apps. It's main purpose is to be used on [Shlink](https://github.com/shlinkio/shlink) project, but any PHP project can take advantage.

Most of the elements it provides require a [PSR-11](https://www.php-fig.org/psr/psr-11/) container, and it's easy to integrate on [mezzio](https://github.com/mezzio/mezzio) applications thanks to the `ConfigProvider` it includes.

Install
-------

[](#install)

Install this library using composer:

```
composer require shlinkio/shlink-common

```

> This library is also a mezzio module which provides its own `ConfigProvider`. Add it to your configuration to get everything automatically set up.

Cache
-----

[](#cache)

This library provides both PSR-6 and PSR-16 cache adapters, via [symfony/cache](https://symfony.com/doc/current/components/cache.html).

They can be fetched via `Psr\Cache\CacheItemPoolInterface` and `Psr\SimpleCache\CacheInterface`.

The concrete implementation they return is different depending on your configuration:

- An `ArrayAdapter` instance when the `debug` config is set to true or when the APCu extension is not installed and the `cache.redis` config is not defined.
- An `ApcuAdapter`instance when no `cache.redis` is defined and the APCu extension is installed.
- A `RedisAdapter` instance when the `cache.redis` config is defined.

The last two adapters will use the namespace defined in `cache.namespace` config entry.

The three of them will allow setting a default lifetime for those entries which do not explicitly define one, picking it up from `cache.default_lifetime`.

```
