Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Card not found #12

Open
avrohomthousman-p opened this issue Feb 20, 2022 · 1 comment
Open

Class Card not found #12

avrohomthousman-p opened this issue Feb 20, 2022 · 1 comment

Comments

@avrohomthousman-p
Copy link

avrohomthousman-p commented Feb 20, 2022

Hi
I downloaded the repo and put it in my project folder. I wrote this php script and ran it:

<title></title> include 'mtg-sdk-php-master/src/Databag.php'; include 'mtg-sdk-php-master/src/QueriesAll.php'; include 'mtg-sdk-php-master/src/QueriesWithConditions.php'; include 'mtg-sdk-php-master/src/QueriesOne.php'; include 'mtg-sdk-php-master/src/Changelog.php'; include 'mtg-sdk-php-master/src/QueriesAllAsArray.php'; include 'mtg-sdk-php-master/src/QueryBuilder.php'; include 'mtg-sdk-php-master/src/Set.php'; include 'mtg-sdk-php-master/src/Subtype.php'; include 'mtg-sdk-php-master/src/Supertype.php'; include 'mtg-sdk-php-master/src/Type.php'; include 'mtg-sdk-php-master/src/Card.php'; $cards = Card::where(['name' => 'Yarok, the Desecrated'])->all(); print_r($cards); ?> </body>

I got this error:
Fatal error: Uncaught Error: Class "Card" not found in C:\xampp\htdocs\WebProgramming\FinalProject\apiTests.php:27 Stack trace: #0 {main} thrown in C:\xampp\htdocs\WebProgramming\FinalProject\apiTests.php on line 27

I don't know if this is relevant but near the top of the Card.php file:
namespace mtgsdk;
is highlighted with the message:

PSR-4 Violation:
Namespace declaration name doesn't correspond to current directory structure

Please help me understand the problem. Why can't it find the Card class?

@cruskai239
Copy link

cruskai239 commented May 12, 2024

If you're not using composer as specified in the installation instructions, you need to autoload the namespace yourself.

Check out the spl_autoload_register method in PHP

https://www.php.net/manual/en/function.spl-autoload-register.php

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

No branches or pull requests

2 participants