0

I'm trying to use the LupeCode\phpTraderNative at https://github.com/LupeCode/phpTraderNative

I'm an "old school BASIC GOTO 10 procedural coding" kinda guy, though I've often used other libraries that use namespaces, objects, classes, and whatnot but there's usually an example included on how to use them. This one hasn't.

The documentation states:

If you had trader_adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod) You can swap that with Trader::adosc($high, $low, $close, $volume, $fastPeriod, $slowPeriod) You only need to change trader_ to Trader::. That's it!

So after installing it with composer and requiring the vendor/autoload.php i'm having a hard time figuring out how to use Trader:: in my code.

Fatal error: Uncaught Error: Class "Trader" not found in

I tried several things like:

use Lupecode\phpTraderNative;

or

$var = new Trader();

And variations, even tried including files from the source. But nothing seems to enable me to use it. Can someone point me in the right direction here?

Santy
  • 387
  • 2
  • 7
  • Ensure you're including the correct Composer autoload file (`vendor/autoload.php`) in the correct directory. If you can't figure it out, edit your question to include information about your directory structure, and how you are including the Composer autoloader. – miken32 May 28 '21 at 01:54
  • 1
    Also note the fully qualified name of the class is `LupeCode\phpTraderNative\Trader` so you'll need to import that (not `LupeCode\phpTraderNative`) before you can do `new Trader()` – miken32 May 28 '21 at 01:56
  • Correct autoload is loaded, other packages installed with composer are working. Thank you @miken32 your answer is correct: "use LupeCode\phpTraderNative\Trader". How did you find the FQN, tho? – Santy May 28 '21 at 10:33
  • I looked at the code. https://github.com/LupeCode/phpTraderNative/blob/master/source/Trader.php – miken32 May 28 '21 at 12:59

1 Answers1

-2

This package is handled by PECL. To install it you can use:

apt-get install php-pear php-dev libcurl3-openssl-dev
pecl install trader
  • The project they link to is described as "A native version of the PHP Trader extension, usable without PECL." – miken32 May 28 '21 at 01:51