PHP code example of gcworld / common

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

    

gcworld / common example snippets




namespace App;

use GCWorld\Common\Common;
use GCWorld\Interfaces\CommonEnvironmentEnumInterface;

final class AppCommon extends Common
{
    protected ?string $configPath = '/path/to/project/config/config.yml';

    public function getEnvironment(): CommonEnvironmentEnumInterface
    {
        return AppEnvironment::LOCAL;
    }
}

$common = AppCommon::getInstance();

$server = $common->getConfig('server');
$database = $common->getDatabase();
$cache = $common->getCache();
$tempDirectory = $common->getDirectory('temp');
$baseUrl = $common->getPath('base');

$primary = $common->getDatabase();
$reporting = $common->getDatabase('reporting');

$defaultCache = $common->getCache();
$workerCache = $common->getCache('default:queue-worker');