我是PHP新手,我试图运行 从 Web3.php 在 Mac 上$exampleBase.php
但它一直显示错误:
PHP 致命错误:未捕获错误:在/Users/hsnl/Desktop/code/back-end-php/web3.php/examples/exampleBase.php:7 中找不到类"Web3\Web3" 堆栈跟踪: #0 {主要} 在第 4 行的/Users/hsnl/Desktop/code/back-end-php/web3.php/examples/exampleBase.php 中
$exampleBase.php
文件是这样的
<?php
require('vendor/autoload.php');
use Web3Web3;
$web3 = new Web3('http://localhost:8545/');
知道为什么或如何解决这个问题吗?
如果您尝试运行sc0Vu,请尝试按照以下步骤操作: https://github.com/sc0Vu/web3.php#local-php-cli-installed
克隆存储库并安装包。
git clone https://github.com/sc0Vu/web3.php.git && cd web3.php && composer install
这意味着:
- 克隆GitHub项目,
- 转到克隆目录,
- 运行编辑器安装 (将下载并创建所有必要的类文件(
运行测试脚本。
vendor/bin/phpunit