PHP code example of the_it_nerd / module-core

1. Go to this page and download the library: Download the_it_nerd/module-core 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/ */

    

the_it_nerd / module-core example snippets


use TheITNerd\Core\Model\CacheClient; 

class TestClass {

    /**
     * @param CacheClient   $cacheClient
     */
    public function __construct(
        private CacheClient   $cacheClient
    )
    {
    }    
    
    public function getData(string $key): array
    {
        //generate an unique cache key
        $cacheKey = md5($key);
        
        if($data = $this->cacheClient->load($cacheKey, 'website')) {
            return $data;
        }
        
        ...
        
        $data = array[]
        
        $this->cacheClient->save($cacheKey, $data, ['tag1, 'tag2'], 86400, 'website');
        
        return $data;
        
    }
    
    ...
}