Laravel Retriever resolves small PHP classes and methods by a string key, then memoizes their return values through Laravel's cache manager. It is useful for reusable, cacheable data providers such as lookup lists, external-data snapshots, and application-level reference data.
composer require nocs/laravel-retrieverLaravel package discovery registers Nocs\\Retriever\\Providers\\RetrieverServiceProvider automatically. The provider binds the retriever manager and scans app/Retrievers and app/Cache during application boot.
Create app/Cache/Colors.php:
<?php
namespace App\Cache;
class Colors
{
public function red(): string
{
return 'red';
}
}Retrieve it from application code:
$value = retriever()->get('colors.red');
// or: $value = retriever('colors.red');The class name and method segment are normalized with Laravel's Str::snake/Str::camel conventions. A class with only a get() method can be addressed as retriever('colors').
- Documentation hub
- Getting started
- Usage
- Reference
- Architecture
- Compatibility
- Testing and verification
composer validate --strict
composer testSee Testing and verification for the CI matrix and source-level checks.
Report security issues privately to the maintainer rather than through the public issue tracker. This package is released under the MIT license.