Reputation: 693
Trying to autoload some files. If i do this in the 'root' composer.json - it works. But when i'm going to load classes and files in 'package composer.json' it doesn't seem to be working at all.
My 'root' composer.json:
{
"repositories": [
{
"type": "git",
"url": "https://bitbucket.org/yuriikrevnyi/bitrix-teil-framework"
}
],
"require": {
"mockery/mockery": "dev-master@dev",
"phpunit/phpunit": "3.7.*",
"yuriikrevnyi/bitrix-teil-framework": "dev-master"
},
"autoload": {
"classmap": [
"vendor/yuriikrevnyi/bitrix-teil-framework/framework/src"
],
"files": [
"vendor/yuriikrevnyi/bitrix-teil-framework/framework/start.php"
]
}
}
And 'package composer.json':
{
"name": "yuriikrevnyi/bitrix-teil-framework",
"description": "Framework for bitrix.",
"homepage": "https://bitbucket.org/yuriikrevnyi/bitrix-teil-framework",
"authors": [
{
"name": "Yurii Krevnyi",
"homepage": "https://bitbucket.org/yuriikrevnyi"
}
],
"autoload": {
"classmap": [
"vendor/yuriikrevnyi/bitrix-teil-framework/framework/src"
],
"files": [
"vendor/yuriikrevnyi/bitrix-teil-framework/framework/start.php"
]
}
}
If i remove autoloads from 'root composer.json' - nothing happens.
I'm using - composer dump-autoload -o, to load files.
Could someone help me a little bit? Thanks!
Upvotes: 1
Views: 821
Reputation: 25701
You shouldn't be referencing the vendor directory. Composer handles that directory for you, but you shouldn't be assuming that things will exist in there.
Assuming that the class files you want to be available to autoload are in $workDIR."yuriikrevnyi/bitrix-teil-framework/src"
and the start.php is in the directory below that, the composer.json in $workDIR."yuriikrevnyi/bitrix-teil-framework/
should have classmap and files entries defined as:
"autoload": {
"classmap": [
"src/"
],
"files": [
"start.php"
]
}
When Composer pulls that dependency into your main project, it will modify the entries to point to the right location in the vendor directory.
Upvotes: 1