Caution
The documentation you are viewing is for an older version of this component.
Switch to the latest (v4) version.
Installation
Standard Installation
To install the library use Composer:
$ composer require laminas/laminas-cache
Installation for a Mezzio or laminas-mvc Application
Installation and Automated Configuration
The laminas-component-installer is the recommended installation method when using in a Mezzio-based or a laminas-mvc-based application. It will automatically inject the config-provider or the module in the configuration during the installation process.
Installation Requirements
The following descriptions depends on the laminas-component-installer component, so be sure to have it installed before getting started.
Global Installation
With a global installation of laminas-component-installer it can be used for all projects without a reinstallation.
$ composer global require laminas/laminas-component-installer
As Development Dependency
$ composer require --dev laminas/laminas-component-installer
Install laminas-cache and Inject Configuration
To install the library use Composer:
$ composer require laminas/laminas-cache
This will install an initial set of dependencies and it will also prompt to inject the component configuration.
- For a Mezzio application, choose
config/config.php
. - For a laminas-mvc application, choose either
modules.config.php
orapplication.config.php
.
If additional dependencies are to be installed, the option for other packages can be remembered.
Installation and Manual Configuration
If the installer is not used, the manual configuration is needed to add the component to the application.
Install laminas-cache
To install the library use Composer:
$ composer require laminas/laminas-cache
Manual Configuration for a Mezzio-based Application
Add the configuration provider of laminas-cache to the configuration file,
e.g. config/config.php
:
$aggregator = new Laminas\ConfigAggregator\ConfigAggregator([
// …
Mezzio\ConfigProvider::class,
Mezzio\Router\ConfigProvider::class,
Laminas\Cache\ConfigProvider, // Add this line
// …
]);
Manual Configuration for a laminas-mvc-based Application
Add laminas-cache as component at the top of the configuration file for
modules, e.g. config/modules.config.php
:
return [
'Laminas\Cache\Module', // Add this line
'Laminas\Router',
'Laminas\Session',
'Laminas\Validator',
'Application',
];
Avoid Unused Cache Adapters Are Being Installed
Only necessary in 2.10+
Starting with 3.0.0, no storage adapter is required by this component and thus, each project has to specify the storage adapters which are required by the project. When migrated to 3.0.0, the
replace
section is not needed anymore.
With laminas-cache
v2.10.0, we introduced satellite packages for all cache adapters.
In case, there is no need for several adapters in your project, you can use composer to ensure these adapters are not being installed. To make this happen, you have to specify a replace
property within the composer.json
of your project.
Example composer.json
with Only Memory Adapter Being Installed
{
"name": "vendor/project",
"description": "",
"type": "project",
"require": {
"laminas/laminas-cache": "^2.10",
"laminas/laminas-cache-storage-adapter-memory": "^1.0"
},
"replace": {
"laminas/laminas-cache-storage-adapter-apc": "*",
"laminas/laminas-cache-storage-adapter-apcu": "*",
"laminas/laminas-cache-storage-adapter-blackhole": "*",
"laminas/laminas-cache-storage-adapter-dba": "*",
"laminas/laminas-cache-storage-adapter-ext-mongodb": "*",
"laminas/laminas-cache-storage-adapter-filesystem": "*",
"laminas/laminas-cache-storage-adapter-memcache": "*",
"laminas/laminas-cache-storage-adapter-memcached": "*",
"laminas/laminas-cache-storage-adapter-mongodb": "*",
"laminas/laminas-cache-storage-adapter-redis": "*",
"laminas/laminas-cache-storage-adapter-session": "*",
"laminas/laminas-cache-storage-adapter-wincache": "*",
"laminas/laminas-cache-storage-adapter-xcache": "*",
"laminas/laminas-cache-storage-adapter-zend-server": "*"
}
}
When using composer install
on this, only the laminas/laminas-cache-storage-adapter-memory
is being installed.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 10 installs, 0 updates, 0 removals
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing psr/cache (1.0.1): Loading from cache
- Installing laminas/laminas-zendframework-bridge (1.2.0): Loading from cache
- Installing laminas/laminas-stdlib (3.3.1): Loading from cache
- Installing psr/container (1.1.1): Loading from cache
- Installing container-interop/container-interop (1.2.0): Loading from cache
- Installing laminas/laminas-servicemanager (3.6.4): Loading from cache
- Installing laminas/laminas-eventmanager (3.3.1): Loading from cache
- Installing laminas/laminas-cache-storage-adapter-memory (1.0.1): Loading from cache
- Installing laminas/laminas-cache (2.10.1): Loading from cache
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Generating autoload files
6 packages you are using are looking for funding.
Use the `composer fund` command to find out more!