PHP code example of loadsys / cakephp-libregistry
1. Go to this page and download the library: Download loadsys/cakephp-libregistry 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/ */
loadsys / cakephp-libregistry example snippets
namespace App\Whatever;
use LibRegistry\LibRegistry;
class MyController extends Controller {
public function index() {
$myObj = LibRegistry::get('MyObj', ['configs' => 'here']);
// (Where the class `src/Lib/MyObj.php` exists.)
$myObj->doSomethingNeat();
}
}
namespace App\Whatever;
use LibRegistry\LibRegistryTrait;
class MyController extends Controller {
use LibRegistryTrait;
public function index() {
$this->loadLib('MyObj', ['configs' => 'here']);
$this->MyObj->doSomethingNeat();
// Works like loadComponent() in this context.
}
}