R
R
Ruslan Karetsky2021-05-01 22:13:56
PHP
Ruslan Karetsky, 2021-05-01 22:13:56

Why aren't the package classes loaded?

Hello. I've been struggling with the issue for two days, I will be glad to help.

I wrote a package for Laravel, the structure is as follows:

  • composer.json
  • config
  • src
    • Exchanges
    • Providers
    • Processor.php



Key points in the composer.json of the package:
"autoload": {
        "classmap": [
            "src"
        ],
        "psr-4": {
            "ExchangeProcessor\\": "src/"
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "ExchangeProcessor\\Providers\\ConfigServiceProvider"
            ]
        }
    }


To pull the package, I wrote the following in composer.json of the main project:

"repositories": [
        {
            "type":"package",
            "package": {
                "name": "exchange-processor",
                "version":"master",
                "source": {
                    "url": "https://github.com/.../exchangeProcessor.git",
                    "type": "git",
                    "reference":"main"
                }
            }
        }
    ],
    "require": {
        ...
        "exchange-processor": "master",
    },


But the problem is that the provider specified in the composer.json of the package does not start.
And when I write $processor = new \ExchangeProcessor/Processor();, I get an error Error : Class "ExchangeProcessor\Processor" not found .

What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question