M
M
Miku Hatsune2015-12-13 22:37:01
PHP
Miku Hatsune, 2015-12-13 22:37:01

How to add your nicespice to the compositor autoloader?

First of all, I went there: https://getcomposer.org/doc/
But either I'm stupid and didn't understand anything, or I'm doing something wrong.
Subject: how to add your nicespice to the example "My\Libs" whose files are located in "vendor/mylibs/", where the file name starts with a capital letter and corresponds to the class name?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2015-12-14
@Hatsune-Miku

Everything that is in the vendor must be loaded by the composer himself, and he himself must know what and how to write (this is described in the composer.json of the vendor package). You just describe in your composer.json which package you need to include:

{
  "require": {
    "slim/slim": "2.*",
    "twig/twig": "~1.18"
  }
}

The namespaces of your project are described in the "autoload" section:
{
  "autoload": {
    "psr-4": {
      "MyName\\MyProject\\": "application"
    }
  }
}

Such an entry indicates the root (I don't know the correct term) namespace for a particular folder. In this case, the %PROJECT__ROOT%/application/ folder will contain files with namespaces starting with MyName\MyProject\
Here I wrote in more detail.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question