I have a small package with 6-7 files (i.e., main class, extending classes, interface, which can be viewed in this link) and I'd like not to use require_once
method to connect these classes together.
What might be the correct way to do so?
I have tried to add them to vendor
directory using composer.
composer require our-new-package-private
and
composer require our-new-package-private ~1.0.0
It returns an error:
[InvalidArgumentException]
Could not find a matching version of package equity-usco. Check the package spelling, your version constraint and that the package is available i
n a stability which matches your minimum-stability (stable).
Do I need to first push the new package to a private GitHub repo, and then run:
composer require our-new-package-private
What might be the correct way to solve this problem and add a new private package or multiple scripts to a PHP-based app? Maybe, I should manually defined it in autoload=>psr-0
or autoload=>psr-4
in composer.json?
Currently it's still not possible to create a composer package from a repository subfolder/ (Github Issue)
You can follow this Packagist link to create your own package.
Define Your Package
Put a file named composer.json at the root of your package's repository, containing this information:
{ "name": "your-vendor-name/package-name", "description": "A short description of what your package does", "require": { "php": "^7.2", "another-vendor/package": "1.*" } }
This is the strictly minimal information you have to give.
For more details about package naming and the fields you can use to document your package better, see the about page.
Commit The File
Add the composer.json to your git or other VCS repository and commit it.
Publish It
Login or register on (the) site, then hit the submit button in the menu.
[...]