1. Go to this page and download the library: Download debuss-a/awareness library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
debuss-a / awareness example snippets
use League\Container\Container;
use Psr\Http\Client\ClientInterface;
use Awareness\ClientAwareInterface;
$container = new Container();
// Register your HTTP client
$container->add(ClientInterface::class, GuzzleClient::class);
// Set up an inflector: any class implementing ClientAwareInterface
// will automatically get the HTTP client injected
$container->inflector(ClientAwareInterface::class)
->invokeMethod('setClient', [ClientInterface::class]);
// Now any ClientAwareInterface implementation gets the client automatically!
$myService = $container->get(MyApiService::class);
// MyApiService now has the HTTP client injected via setClient()
use Awareness\CacheAwareInterface;
use Awareness\CacheAwareTrait;
class MyService implements CacheAwareInterface
{
use CacheAwareTrait;
public function doSomething()
{
// Access the cache through $this->cache
$this->cache->set('key', 'value');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.