I work with composer for the first time. I started the "composer init", created the project, installed all the necessary dependencies. Now I want to put my "package" in the vendor folder. I created a folder there, and in it another one, it turned out something like 'vendor / author / package'. In the final folder put the file composer.json with the following contents:

{ "name": "author/package", "description": "Description my package", "license": "FREE", "authors": [ { "name": "Author Name", "email": "author@gmail.com" } ], "require": { "php": ">=7.0" }, "autoload": { "psr-4": { "Author\\Package\\": "" } }, "minimum-stability": "dev" } 

And when I call my class in code

 $myClass = new \Author\Package\Myclass; 

Autoloader does not find it. I understand that the case is in the first letter case. Tell me how to “teach” the composer to see my package in exactly this format as it is, that is, the name of the folders in lower case, and the namespace each word with a large one. Thank.

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

It is not necessary in the vendors just to vendors something down. Instead, add your module depending.

Example composer.json parent project:

 { ... "require": { ... "component-name": "dev-master" // см. пункт 1, 2 }, ... "repositories": [ { "type": "git", "url": "https://github.com/author/package.git" // см. пункт 3 } ] } 
  1. The value of the component-name must match the name from the composer.json component
  2. dev-master , in order to pull off branches from the master , or vX.YZ , if tags are added to the repository ( tags , branches )
  3. author/package may not be the same as the above ( documentation )

If the repository is private, you can start from here HTTP basic authentication