Checking my own composition package doesn't work
I want to create a composite package. However, I'm still in the development stage, there would or will be, but an earlier test.
I have an empty folder vendor
with autoloader from composer:
/vendor /composer autoload.php
So now I tried my package "simulate" and created my folder structure and composer.json:
/vendor
/composer
/me
/package
/src
/tests
composer.json
autoload.php
This is my composer .json:
{
"name": "me/package",
"description": "",
"license": "",
"authors": [
{
"name": "",
"email": ""
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0"
},
"autoload": {
"psr-4": {
"Me\\Package\\": "src/"
}
}
}
And here is my class:
namespace Me\Package;
class Test {
// ...
}
If I want to call this:
if(file_exists('vendor/autoload.php')) require 'vendor/autoload.php';
$test = new \Me\Package\Test();
i becomes Fatal error: Class 'Me\Package\Test' not found
.
Of course, I also pasted composer.json in the root directory, but I may still be bad at the require
state of my package since it hasn't been published, right? But how do I check this and tell the composer to autoload my package?
source to share
If you want to use composer to include a package that is not listed in http://Packagist.org/ , you must add ' repositories ' to composer .json (project root file). This reads the project and gets the composer .json from it using the section name main-askquires.
"repositories": [
{
"type": "vcs",
"url": "https://github.com/example/private-repo.git"
}
}
The 'url' part can also be actually a valid URL for a git, SVN, or HG repository - even a file link: //.
source to share