-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from boesing/feature/storage-adapter-factory-b…
…ackport-v2 storage adapter factory backport to v2
- Loading branch information
Showing
20 changed files
with
974 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Basic Usage | ||
|
||
## Standalone | ||
|
||
If this component is used without `laminas-mvc` or `mezzio`, a PSR-11 container to fetch services, adapters, plugins, etc. is needed. | ||
|
||
The easiest way would be to use [laminas-config-aggregator](https://docs.laminas.dev/laminas-config-aggregator/) along with [laminas-servicemanager](https://docs.laminas.dev/laminas-servicemanager/). | ||
|
||
```php | ||
use Laminas\Cache\ConfigProvider; | ||
use Laminas\Cache\Service\StorageAdapterFactoryInterface; | ||
use Laminas\Cache\Storage\Adapter\Memory; | ||
use Laminas\ConfigAggregator\ConfigAggregator; | ||
use Laminas\ServiceManager\ServiceManager; | ||
|
||
$config = (new ConfigAggregator([ | ||
ConfigProvider::class, | ||
]))->getMergedConfig(); | ||
|
||
$dependencies = $config['dependencies']; | ||
|
||
$container = new ServiceManager($dependencies); | ||
|
||
/** @var StorageAdapterFactoryInterface $storageFactory */ | ||
$storageFactory = $container->get(StorageAdapterFactoryInterface::class); | ||
|
||
$storage = $storageFactory->create(Memory::class); | ||
|
||
$storage->setItem('foo', 'bar'); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.