Tustin / psn-php

A PHP wrapper for the PSN API
https://tustin.dev/psn-php/
MIT License
354 stars 73 forks source link

Class "App\Http\Controllers\Tustin\PlayStation\Client" not found #205

Closed spypix3l closed 2 years ago

spypix3l commented 2 years ago

Hi,

I'm been stuck for an hour with this issue : Class "App\Http\Controllers\Tustin\PlayStation\Client" not found. I've found the code that was downloaded by composer doesn't seem to be the same as on Git. (ex : Namespace is PSN on what composer downloaded in my project).

I found these issues that seem to be quite similar : https://github.com/Tustin/psn-php/issues/195 https://github.com/Tustin/psn-php/issues/98

I'm wondering if this could be due to my PHP version that is too recent (8.1.4) : composer install tustin/psn-php invites me to use composer require tustin/psn-php instead. I noticed this command line adds the 1.2 version of tustin/psn-php in composer.json, and not the latest (that I guess is 3.0).

Is this library compatible with my version of PHP ?

Thanks, Spypix3l

jbdabes commented 2 years ago

Guessing this is a Laravel project - you need to use \Tustin\PlayStation\Client and not Tustin\PlayStation\Client otherwise you will be loading from the wrong namespace.

Alternatively, you can include this at the top of your file:

use \Tustin\PlayStation\Client;

Then use Client::method() or $client = new Client();

spypix3l commented 2 years ago

Thank you for your answer @jbdabes . It will be useful. However, as explained above, it seems like anyway the version of the library that was downloaded from composer is wrong. Reading the issues listed in my previous message, I understand this might be due to my version of PHP.

Is there a workaround that would allow me to install the right version ? (update the composer.json manually seems to have no effect : when I use the "composer require tustin/psn-php" command line, the composer.json file is updated with ^1.2, and the v1.2 is installed, instead of the recent version of the library).

Thank you,

jbdabes commented 2 years ago

I don't believe the library has been tested against 8.1 yet, although I am guessing it likely works fine. Run the tests against 8.1 and if they pass, maybe submit a PR to add 8.1 support to composer.json.

jbdabes commented 2 years ago

I've submitted an update after verifying that the tests pass on 8.1. For now, if you target dev-master as the version you should pull the latest version from Github rather than the 3.0.0 release which will work on 8.1.

Ragowit commented 2 years ago

I'm using the library with 8.1, the only problem is deprecation messages in your error log. See #194

spypix3l commented 2 years ago

@jbdabes Thank you. The composer require tustin/psnphp:dev-master command line worked. I'm now good to go with my development !

Thank you @ragowit, i'll look at the updates on this Issue.