(MAC) PHP Fatal error: Uncaught Error: Class 'Web3\Web3' not found

872 views Asked by At

I'm new to PHP, and I was trying to run $exampleBase.php from web3.php on mac
but it keeps showing error :

PHP Fatal error: Uncaught Error: Class 'Web3\Web3' not found in /Users/hsnl/Desktop/code/back-end-php/web3.php/examples/exampleBase.php:7 Stack trace: #0 {main} thrown in /Users/hsnl/Desktop/code/back-end-php/web3.php/examples/exampleBase.php on line 4

$exampleBase.php file is like this

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

any idea why or how should I fix this?

1

There are 1 answers

0
Vitalijs G. On

If you are trying to run sc0Vu, please try to follow this steps: https://github.com/sc0Vu/web3.php#local-php-cli-installed

Clone the repo and install packages.

git clone https://github.com/sc0Vu/web3.php.git && cd web3.php && composer install

This means:

  • clone github project,
  • go to cloned directory,
  • run composer install (will download and create all necessary files with classes)

Run test script.

vendor/bin/phpunit