Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Cant load web3-php #26

Closed
jose5958 opened this issue Feb 6, 2022 · 1 comment
Closed

Cant load web3-php #26

jose5958 opened this issue Feb 6, 2022 · 1 comment

Comments

@jose5958
Copy link

jose5958 commented Feb 6, 2022

I am not an expert, i am having this trouble.
First i created a composer.json:

{
"minimum-stability": "dev",

}

then, in visual code, from terminal, i wrote this command:
"composer require web3-php/web3"
and terminal thorw this:

Using version dev-master for web3-php/web3
./composer.json has been updated
Running composer update web3-php/web3
Loading composer repositories with package information
Updating dependencies
Lock file operations: 12 installs, 0 updates, 0 removals

  • Locking guzzlehttp/guzzle (dev-master c1fd316)
  • Locking guzzlehttp/promises (dev-master fe752ae)
  • Locking guzzlehttp/psr7 (dev-master c5b547b)
  • Locking paragonie/constant_time_encoding (v2.5.0)
  • Locking paragonie/random_compat (v9.99.100)
  • Locking phpseclib/phpseclib (3.0.x-dev 60edff7)
  • Locking psr/http-client (dev-master 22b2ef5)
  • Locking psr/http-factory (dev-master 36fa03d)
  • Locking psr/http-message (dev-master efd67d1)
  • Locking ralouphie/getallheaders (3.0.3)
  • Locking symfony/deprecation-contracts (dev-main 893fd20)
  • Locking web3-php/web3 (dev-master 061828b)
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 12 installs, 0 updates, 0 removals
  • Downloading psr/http-message (dev-master efd67d1)
  • Downloading psr/http-factory (dev-master 36fa03d)
  • Downloading guzzlehttp/psr7 (dev-master c5b547b)
  • Downloading psr/http-client (dev-master 22b2ef5)
  • Downloading symfony/deprecation-contracts (dev-main 893fd20)
  • Downloading phpseclib/phpseclib (3.0.x-dev 60edff7)
  • Downloading guzzlehttp/guzzle (dev-master c1fd316)
  • Installing guzzlehttp/promises (dev-master fe752ae): Extracting archive
  • Installing ralouphie/getallheaders (3.0.3): Extracting archive
  • Installing psr/http-message (dev-master efd67d1): Extracting archive
  • Installing psr/http-factory (dev-master 36fa03d): Extracting archive
  • Installing guzzlehttp/psr7 (dev-master c5b547b): Extracting archive
  • Installing paragonie/random_compat (v9.99.100): Extracting archive
  • Installing psr/http-client (dev-master 22b2ef5): Extracting archive
  • Installing symfony/deprecation-contracts (dev-main 893fd20): Extracting archive
  • Installing phpseclib/phpseclib (3.0.x-dev 60edff7): Extracting archive
  • Installing guzzlehttp/guzzle (dev-master c1fd316): Extracting archive
  • Installing web3-php/web3 (dev-master 061828b): Extracting archive
    7 package suggestions were added by new dependencies, use composer suggest to see details.
    Generating autoload files
    6 packages you are using are looking for funding.
    Use the composer fund command to find out more!

And in folder, appear the composer.lock and vendor folder with a bunch of stuff installed.
imagen

imagen

Inside the vendor folder there is an autoload.php file, which has this code in it:

// autoload.php @generated by Composer

require_once DIR . '/composer/autoload_real.php';

return ComposerAutoloaderInit9f1c798e6bb2829771949001eeeee0c7::getLoader();

so i want to make a test, and add the following to the autoload.php file:

// autoload.php @generated by Composer

require_once DIR . '/composer/autoload_real.php';

return ComposerAutoloaderInit9f1c798e6bb2829771949001eeeee0c7::getLoader();

print ("test");

Then go to my browser, http://localhost/web3ppp/vendor/autoload.php and nothing happend:
imagen

but if i put the
print ("test"); before the return line, the text "test" appear,

// autoload.php @generated by Composer

require_once DIR . '/composer/autoload_real.php';

print ("test");

return ComposerAutoloaderInit9f1c798e6bb2829771949001eeeee0c7::getLoader();

imagen

so there is something wrong with the return line, but i dont know what is wrong.

Im using xampp with php 8.0.6 on windows 10.

Can anyone tell me what im doing wrong?

@owenvoke
Copy link
Member

owenvoke commented Feb 7, 2022

You may want to have a look at how Composer works overall, but you should be requiring vendor/autoload.php from your project (outside of the vendor directory), rather than accessing the autoloader directly. 🙂

For example, if you added an index.php file in your web3ppp directory. You can add:

<?php

require __DIR__.'/vendor/autoload.php';

use Web3\Web3;

$web3 = new Web3('http://127.0.0.1:8545');

// ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants