I've been playing with this for hours now, finding all kind of autoloaders but I can't figure it out:
declare(strict_types=1);
function __autoload($class_name)
{
//class directories
$directorys = array(
'EthereumRPC/',
'EthereumRPC/API/',
'EthereumRPC/API/Personal/',
'EthereumRPC/Contracts/',
'EthereumRPC/Contracts/ABI/',
'EthereumRPC/Exception/',
'EthereumRPC/Response/',
'ERC20/',
'ERC20/data/',
'ERC20/Exception/'
);
//for each directory
foreach($directorys as $directory)
{
//see if the file exsists
if(file_exists($directory.$class_name . '.php'))
{
require_once($directory.$class_name . '.php');
//only require the class once, so quit after to save effort (if you got more, then name them something else
return;
}
}
}
use EthereumRPC\EthereumRPC;
use ERC20\ERC20;
I load every directory that contains classes but I still end up with the error:
Fatal error: Uncaught Error: Class 'EthereumRPC\EthereumRPC' not found in /home/sewicumg/public_html/contenthourlies.com/wp-content/themes/seoexp/account_client.php:62
The instruction file said to only include the two lines at the bottom but that definitely didn't work.
Am I missing something?
Here is the code that uses the classes:
$geth = new EthereumRPC('127.0.0.1', 8545);
$erc20 = new ERC20($geth);
All those EthereumRPC and ERC20 folders are in the same directory as the php file that this code is in.
Am I missing something here?