2

I am trying to include a package from composer, but I am receiving a class not found error.

I have tried the below possibilities.

$supermeteor = new \Supermeteor\Supermeteor('XXXXXXXX');

and

use Supermeteor\Supermeteor;
$supermeteor = new Supermeteor('xxxxxxxx');

Packages composer.json:

"psr-4": {
     "Supermeteor\\": ""
}

Packages namespace :

namespace Supermeteor;

Packages class name :

class Supermeteor() {}

Error message

Uncaught Error: Class 'Supermeteor\Supermeteor' not found in C:\path\to\my\file.php:16

1
  • What does your file structure look like? Where is the Supermeteor class file in relation to your composer.json? Commented Jun 14, 2019 at 2:44

1 Answer 1

2

I just tested your package locally, and it seems to work fine for me using the same code as you provided in your question. This is how I tested it.

1. Create a new project

Create a new directory on your computer.

2. Add the package to a new project using Composer

Locate your new directory on the command line and add the package to your projects autoloader by running the below composer command.

composer require supermeteor/sdk-php

3. Use the package

Create an index.php file in the same directory as your composer.json and add the below code.

<?php
require_once __DIR__ . '/vendor/autoload.php';

use Supermeteor\Supermeteor;

$supermeteor = new Supermeteor("xxx");

4. Test the results

In the terminal window start a new php server to serve your project.

php -S localhost:8089

Now access the site via your browser at http://localhost:8089.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks its worked. I forgot to include require_once DIR . '/vendor/autoload.php'; this line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.