(MAC)PHP致命错误:未捕获错误:找不到类'Web3 \ Web3'

问题描述 投票:0回答:1

我是PHP的新手,我试图在mac上运行web3.php中的$exampleBase.php 但它一直显示错误:

PHP致命错误:未捕获错误:在/Users/hsnl/Desktop/code/back-end-php/web3.php/examples/exampleBase.php:7中找不到类'Web3 \ Web3'。堆栈跟踪:#0 {main}在第4行的/Users/hsnl/Desktop/code/back-end-php/web3.php/examples/exampleBase.php中引发

$exampleBase.php文件是这样的

<?php
require('vendor/autoload.php');
use Web3\Web3;
$web3 = new Web3('http://localhost:8545/');

知道为什么或如何解决这个问题?

php ethereum web3
1个回答
0
投票

如果您尝试运行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项目,
  • 转到克隆目录,
  • 运行composer install(将下载并使用类创建所有必需的文件)

运行测试脚本。

vendor/bin/phpunit

© www.soinside.com 2019 - 2024. All rights reserved.