I'm trying to use https://github.com/phpWhois/phpWhois in my PHP scripts, but can't get it to work. I'm an absolute beginner when it comes to using Composer.
This is what I tried:
- Cloned the git repo locally
- Installed Composer for Windows
- In Powershell, navigated to the local repository
- Typed
composer require
. Composer first asked me:Search for a package:
, where I simply pressedENTER
. Then, Composer installed various packages in the vendor directory (phpunit, symfony, sebastian, etc.), and it created anautoload.php
file.
But if I include that autoload.php
in my example script (the basic example on the phpWhois Github main page), it generates the following error:
Fatal error: Class 'phpWhois\Whois' not found in /home/myServer/www/myApp/api/whoistest.php on line 12
Well, the Installation manual on the Github page says I should run
php composer.phar require "phpwhois/phpwhois":"~4.0"
So I tried the following in the Powershell console:
composer require "phpwhois/phpwhois":"~4.0"
[UnexpectedValueException]
Could not parse version constraint :~4.0: Invalid version string ":~4.0"
Then this:
composer require "phpwhois/phpwhois"
Problem 1
- Conclusion: remove phpwhois/phpwhois dev-master
- Can only install one of: phpwhois/phpwhois[dev-master, 4.2.3].
- Can only install one of: phpwhois/phpwhois[dev-master, 4.2.4].
- Can only install one of: phpwhois/phpwhois[v4.2.5, dev-master].
- Installation request for phpwhois/phpwhois dev-master -> satisfiable by phpwhois/phpwhois[dev-master].
- Installation request for phpwhois/phpwhois ^4.2 -> satisfiable by phpwhois/phpwhois[4.2.3, 4.2.4, v4.2.5].
Then this:
composer require "phpwhois/phpwhois:~4.0"
which gave the same error as above.
I tried various other syntaxes to specify the version here, but none of them worked.
Any ideas?