3

I have an issue with the class loading of classes.

After installing my package it does not find the class, here is its error message:

   Illuminate\Contracts\Container\BindingResolutionException  : Target class [SundayIT\ChatbotAdmin\Commands\DBM_RealtimeStats] does not exist.

Here is first few lines of the class that is missed by the autoloader:

<?php
    namespace SundayIT\ChatbotAdmin\Commands;

    use Illuminate\Console\Command;
    use Illuminate\Support\Facades\DB;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;

    class DBM_RealtimeStats extends Command

Here is the relevant part of the package's composer.json file

    "autoload": {
        "psr-4": {
            "SundayIT\\ChatbotAdmin\\": "src/"
        }
    },

And here is the file structure: Directory screenshot

What am I missing? I have tried checking the other questions here, but I have not found a solution. Thank you

3
  • Thanks for the answer, yes, I did tried that and it gives the same message:` Illuminate\Contracts\Container\BindingResolutionException : Target class [SundayIT\ChatbotAdmin\Commands\DBM_RealtimeStats] does not exist. at C:\Users\molba\PhpstormProjects\example_chatbot\vendor\laravel\framework\src\Illuminate\Container\Container.php:809 ` Commented Sep 20, 2019 at 18:20
  • 1
    Have you tried renaming your class to DbmRealtimeStats and the file to DbmRealtimeStats.php? Commented Sep 21, 2019 at 7:00
  • Try Adding classmap section in composer.json > autoload section Commented Sep 21, 2019 at 11:09

1 Answer 1

1

According to the PSR-4 standard class names should not contain underscores.

Underscores have no special meaning in any portion of the fully qualified class name.

That's why renaming the class to DbmRealtimeStats and the file to DbmRealtimeStats.php worked (as mentioned here).

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

Comments

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.