I want to add custom php API library under vendor
folder and I have added the following folder and files under vendor folder.
- magento2_root>vendor/abc/
- magento2_root>vendor/abc/abc_php/
- magento2_root>vendor/abc/abc_php/composer.json
- magento2_root>vendor/abc/abc_php/lib/
- magento2_root>vendor/abc/abc_php/lib/Test.php
magento2_root>vendor/abc/abc_php/composer.json
{
"name": "abc/abc_php",
"type": "library",
"description": "ABC PHP Client Library",
"license": "MIT",
"authors": [
{
"name": "Custom Author",
}
],
"require": {
"php": ">=5.4.0"
},
"autoload": {
"psr-4": {
"CustomApi\\": "lib"
}
}
}
magento2_root>vendor/abc/abc_php/lib/Test.php
<?php
namespace CustomApi;
class Test
{
public function customMethod(){
return "abc";
}
}
When I include this in constructor like following
public function __construct(
...
\CustomApi\Test $testApi,
...
){
// do some logic
}
It gives me Class CustomApi\Test does not exist
error.
PS : I have recompiled the composer by using composer dumpautoload
command. It does not generate autoload script in autoload_psr4.php under vendor/composer
folder.
Can anyone tell me that what I did wrong ? Any suggestion would be appreciated.
Thanks