PHP code example of icaine / renamed-class-loader
1. Go to this page and download the library: Download icaine/renamed-class-loader 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/ */
icaine / renamed-class-loader example snippets
//registering classes
$loader = new iCaine\RenamedClassLoader([
'Old\\Class\\Name' => 'New\\Class\\Name'
]);
//or like this
$loader->registerClass('Old\\Class\\Name', 'New\\Class\\Name');
//or this way
$loader->registerClasses([
'Old\\Class\\Name' => 'New\\Class\\Name'
]);
//we can register a callback(s) when the loader successfully loads old class
$loader->onClassLoaded[] = function($oldName, $newName) {
trigger_error("Old class name used: '$oldName'. Use new name '$newName' instead.", E_USER_DEPRECATED);
};
//now lets register the loader (uses spl_autoload_register function)
$loader->register();