A
A
Aricus2021-04-29 12:02:07
PHP
Aricus, 2021-04-29 12:02:07

Why doesn't autoloading my classes through composer work?

There is a project on which composer successfully works with connected libraries. I also wanted to use it to autoload my own classes. I used this manual for the most part .
In the main composer folder (where composer.json) I created a control folder, moved the classes there. For example, in control/Standart/MyCrypt.php:

<?php namespace Control\Standart;
class MyCrypt {

Accordingly, application: In composer.json added:
use Control\Standart\MyCrypt;
...
  "autoload": {
    "psr-4": {"Control\\": "control"}
  }
}

/vendor/autoload.php is included (otherwise external libraries would not work).
I executed the "composer dump-autoload -o" command, and added to /vendor/composer/autoload_pcr4.php Files are not loaded. Where did I go wrong?
'Control\\' => array($baseDir . '/control'),

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Komarov, 2021-04-29
@maNULL

Put a slash after the directory name{"Control\\": "control/"}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question