Magento 2: Cannot load my library using composer Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?sample data not loading in 0.74.0-beta10main.CRITICAL: Plugin class doesn't existHow to use a library using composer in a Magento 2 moduleMagento 2: Plugin class does not existMagento 2 : how to LIbrary import using composerPHP fatal error: Uncaught TypeError: Argument 2 passed to MagentoCatalogPluginBlockTopmenuMagento 2 load component composer dependenciesMagento 2.3 Can't view module's front end page output?Magento 2.3.0 - The store that was requested wasn't foundError Database Magento 2.3 migration from localhost to server

Can a party unilaterally change candidates in preparation for a General election?

How to show element name in portuguese using elements package?

What would be the ideal power source for a cybernetic eye?

Is there such thing as an Availability Group failover trigger?

What is this building called? (It was built in 2002)

Delete nth line from bottom

Why are the trig functions versine, haversine, exsecant, etc, rarely used in modern mathematics?

An adverb for when you're not exaggerating

What is the escape velocity of a neutron particle (not neutron star)

How do I stop a creek from eroding my steep embankment?

Why are both D and D# fitting into my E minor key?

Irreducible of finite Krull dimension implies quasi-compact?

What do you call the main part of a joke?

Can anything be seen from the center of the Boötes void? How dark would it be?

Fantasy story; one type of magic grows in power with use, but the more powerful they are, they more they are drawn to travel to their source

How to Make a Beautiful Stacked 3D Plot

Amount of permutations on an NxNxN Rubik's Cube

Why aren't air breathing engines used as small first stages

Is there a holomorphic function on open unit disc with this property?

For a new assistant professor in CS, how to build/manage a publication pipeline

What is the longest distance a player character can jump in one leap?

First console to have temporary backward compatibility

Does classifying an integer as a discrete log require it be part of a multiplicative group?

Is there any way for the UK Prime Minister to make a motion directly dependent on Government confidence?



Magento 2: Cannot load my library using composer



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?sample data not loading in 0.74.0-beta10main.CRITICAL: Plugin class doesn't existHow to use a library using composer in a Magento 2 moduleMagento 2: Plugin class does not existMagento 2 : how to LIbrary import using composerPHP fatal error: Uncaught TypeError: Argument 2 passed to MagentoCatalogPluginBlockTopmenuMagento 2 load component composer dependenciesMagento 2.3 Can't view module's front end page output?Magento 2.3.0 - The store that was requested wasn't foundError Database Magento 2.3 migration from localhost to server



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Sorry for the lengthy message. I just wanted to provide as much information as possible. I am writing a new module. I have a custom library that I need to load to use in my module. I have the library classes in vendor/easyask/easyask_search/lib/EasyAsk/Impl. The module is in app/code/EasyAsk/Search.



When I try to invoke EasyAskImplRemoteFactory, I get a class does not exist error. I know the lib files are not autoloaded as I don't see them referenced in vendor/composer/autoload_namespaces.php file.



Can somebody tell me what I'm doing wrong?



Here is the composer.json in my module




"name": "easyask/module-search",
"description": "A better search module from EasyAsk",
"require":
"php": "~5.5.0,
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"extra":
"map": [
[
"*",
"EasyAsk/Search"
]
]





Here is the composer.json from vendor/easyask/easyask_search directory




"name": "easyask/easyask_search",
"type": "magento2-library",
"description": "EasyAsk Search PHP Client Library",
"license": "N/A",
"authors": [

"name": "EasyAsk",
"homepage": "http://www.easyask.com"

],
"require":
"php": ">=5.2.1",
"ext-curl": "*",
"ext-dom": "*",
"ext-hash": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*"
,
"require-dev":
"phpunit/phpunit": "3.7.*"
,
"autoload":
"psr-0":
"EasyAsk": "lib"






Part of controller class where I'm trying to inject RemoteFactory



use MagentoFrameworkEventManager;
use EasyAskImplRemoteFactory;

class Index extends MagentoCatalogSearchControllerResultIndex
{
/**
* @var QueryFactory
*/
private $_queryFactory;

/**
* Catalog Layer Resolver
*
* @var Resolver
*/
private $layerResolver;

protected $scopeConfig;

protected $_eventManager;

protected $_remoteFactory;

/**
* @param Context $context
* @param Session $catalogSession
* @param StoreManagerInterface $storeManager
* @param QueryFactory $queryFactory
* @param Resolver $layerResolver
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Context $context,
Session $catalogSession,
StoreManagerInterface $storeManager,
QueryFactory $queryFactory,
Resolver $layerResolver,
ScopeConfigInterface $scopeConfig,
Manager $eventManager,
RemoteFactory $remoteFactory
)
parent::__construct($context, $catalogSession, $storeManager, $queryFactory, $layerResolver);
$this->_storeManager = $storeManager;
$this->_catalogSession = $catalogSession;
$this->_queryFactory = $queryFactory;
$this->layerResolver = $layerResolver;
$this->scopeConfig = $scopeConfig;
$this->_eventManager = $eventManager;
$this->_remoteFactory = $remoteFactory;



Let me know if you need any more information.










share|improve this question
























  • What version of 2.0 are you running (1.0.0-beta)? You should take a look at the latest 2.0.x version because there are some changes to composer.json. Also take a look at alankent.me/2015/10/13/…

    – Renon Stewart
    Feb 23 '16 at 17:29












  • I am using the beta version. Let me download the latest version and try it again. Thanks.

    – Srinivas
    Feb 23 '16 at 21:18











  • I downloaded 2.0.2, installed it, did all the upgrades, made sure the site is working as expected. Added my module and made sure the controller class is getting called. I tried psr-4 approach without any luck. Maybe my approach to this problem is wrong. Let me state what I am trying to do. I want somebody to comment on the correct approach. I have a module that has all the stuff (blocks, controller, models etc), in Magento 1 I had the library files (bunch of files that makes a curl request to a server and parse the JSON response into php objects) in lib directory. Based on my

    – Srinivas
    Feb 25 '16 at 20:55











  • understanding I tried to add the lib files in vendor. that did not work. After further reading I placed the files in <magento install dir>/lib. The structure is lib/easyask/easyask/lib/EasyAsk/Impl. I have composer.json file in lib/easyask/easyask directory that has "autoload": "psr-4": "EasyAsk\": "lib/" . Is this the right approach? BTW, this did not work either. When i did setup:di:compile, I get Class does not exist error for EasyAskImpleRemoteFactory. Should I just place the files in app/code/EasyAsk/lib directory?

    – Srinivas
    Feb 25 '16 at 21:02

















0















Sorry for the lengthy message. I just wanted to provide as much information as possible. I am writing a new module. I have a custom library that I need to load to use in my module. I have the library classes in vendor/easyask/easyask_search/lib/EasyAsk/Impl. The module is in app/code/EasyAsk/Search.



When I try to invoke EasyAskImplRemoteFactory, I get a class does not exist error. I know the lib files are not autoloaded as I don't see them referenced in vendor/composer/autoload_namespaces.php file.



Can somebody tell me what I'm doing wrong?



Here is the composer.json in my module




"name": "easyask/module-search",
"description": "A better search module from EasyAsk",
"require":
"php": "~5.5.0,
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"extra":
"map": [
[
"*",
"EasyAsk/Search"
]
]





Here is the composer.json from vendor/easyask/easyask_search directory




"name": "easyask/easyask_search",
"type": "magento2-library",
"description": "EasyAsk Search PHP Client Library",
"license": "N/A",
"authors": [

"name": "EasyAsk",
"homepage": "http://www.easyask.com"

],
"require":
"php": ">=5.2.1",
"ext-curl": "*",
"ext-dom": "*",
"ext-hash": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*"
,
"require-dev":
"phpunit/phpunit": "3.7.*"
,
"autoload":
"psr-0":
"EasyAsk": "lib"






Part of controller class where I'm trying to inject RemoteFactory



use MagentoFrameworkEventManager;
use EasyAskImplRemoteFactory;

class Index extends MagentoCatalogSearchControllerResultIndex
{
/**
* @var QueryFactory
*/
private $_queryFactory;

/**
* Catalog Layer Resolver
*
* @var Resolver
*/
private $layerResolver;

protected $scopeConfig;

protected $_eventManager;

protected $_remoteFactory;

/**
* @param Context $context
* @param Session $catalogSession
* @param StoreManagerInterface $storeManager
* @param QueryFactory $queryFactory
* @param Resolver $layerResolver
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Context $context,
Session $catalogSession,
StoreManagerInterface $storeManager,
QueryFactory $queryFactory,
Resolver $layerResolver,
ScopeConfigInterface $scopeConfig,
Manager $eventManager,
RemoteFactory $remoteFactory
)
parent::__construct($context, $catalogSession, $storeManager, $queryFactory, $layerResolver);
$this->_storeManager = $storeManager;
$this->_catalogSession = $catalogSession;
$this->_queryFactory = $queryFactory;
$this->layerResolver = $layerResolver;
$this->scopeConfig = $scopeConfig;
$this->_eventManager = $eventManager;
$this->_remoteFactory = $remoteFactory;



Let me know if you need any more information.










share|improve this question
























  • What version of 2.0 are you running (1.0.0-beta)? You should take a look at the latest 2.0.x version because there are some changes to composer.json. Also take a look at alankent.me/2015/10/13/…

    – Renon Stewart
    Feb 23 '16 at 17:29












  • I am using the beta version. Let me download the latest version and try it again. Thanks.

    – Srinivas
    Feb 23 '16 at 21:18











  • I downloaded 2.0.2, installed it, did all the upgrades, made sure the site is working as expected. Added my module and made sure the controller class is getting called. I tried psr-4 approach without any luck. Maybe my approach to this problem is wrong. Let me state what I am trying to do. I want somebody to comment on the correct approach. I have a module that has all the stuff (blocks, controller, models etc), in Magento 1 I had the library files (bunch of files that makes a curl request to a server and parse the JSON response into php objects) in lib directory. Based on my

    – Srinivas
    Feb 25 '16 at 20:55











  • understanding I tried to add the lib files in vendor. that did not work. After further reading I placed the files in <magento install dir>/lib. The structure is lib/easyask/easyask/lib/EasyAsk/Impl. I have composer.json file in lib/easyask/easyask directory that has "autoload": "psr-4": "EasyAsk\": "lib/" . Is this the right approach? BTW, this did not work either. When i did setup:di:compile, I get Class does not exist error for EasyAskImpleRemoteFactory. Should I just place the files in app/code/EasyAsk/lib directory?

    – Srinivas
    Feb 25 '16 at 21:02













0












0








0








Sorry for the lengthy message. I just wanted to provide as much information as possible. I am writing a new module. I have a custom library that I need to load to use in my module. I have the library classes in vendor/easyask/easyask_search/lib/EasyAsk/Impl. The module is in app/code/EasyAsk/Search.



When I try to invoke EasyAskImplRemoteFactory, I get a class does not exist error. I know the lib files are not autoloaded as I don't see them referenced in vendor/composer/autoload_namespaces.php file.



Can somebody tell me what I'm doing wrong?



Here is the composer.json in my module




"name": "easyask/module-search",
"description": "A better search module from EasyAsk",
"require":
"php": "~5.5.0,
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"extra":
"map": [
[
"*",
"EasyAsk/Search"
]
]





Here is the composer.json from vendor/easyask/easyask_search directory




"name": "easyask/easyask_search",
"type": "magento2-library",
"description": "EasyAsk Search PHP Client Library",
"license": "N/A",
"authors": [

"name": "EasyAsk",
"homepage": "http://www.easyask.com"

],
"require":
"php": ">=5.2.1",
"ext-curl": "*",
"ext-dom": "*",
"ext-hash": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*"
,
"require-dev":
"phpunit/phpunit": "3.7.*"
,
"autoload":
"psr-0":
"EasyAsk": "lib"






Part of controller class where I'm trying to inject RemoteFactory



use MagentoFrameworkEventManager;
use EasyAskImplRemoteFactory;

class Index extends MagentoCatalogSearchControllerResultIndex
{
/**
* @var QueryFactory
*/
private $_queryFactory;

/**
* Catalog Layer Resolver
*
* @var Resolver
*/
private $layerResolver;

protected $scopeConfig;

protected $_eventManager;

protected $_remoteFactory;

/**
* @param Context $context
* @param Session $catalogSession
* @param StoreManagerInterface $storeManager
* @param QueryFactory $queryFactory
* @param Resolver $layerResolver
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Context $context,
Session $catalogSession,
StoreManagerInterface $storeManager,
QueryFactory $queryFactory,
Resolver $layerResolver,
ScopeConfigInterface $scopeConfig,
Manager $eventManager,
RemoteFactory $remoteFactory
)
parent::__construct($context, $catalogSession, $storeManager, $queryFactory, $layerResolver);
$this->_storeManager = $storeManager;
$this->_catalogSession = $catalogSession;
$this->_queryFactory = $queryFactory;
$this->layerResolver = $layerResolver;
$this->scopeConfig = $scopeConfig;
$this->_eventManager = $eventManager;
$this->_remoteFactory = $remoteFactory;



Let me know if you need any more information.










share|improve this question
















Sorry for the lengthy message. I just wanted to provide as much information as possible. I am writing a new module. I have a custom library that I need to load to use in my module. I have the library classes in vendor/easyask/easyask_search/lib/EasyAsk/Impl. The module is in app/code/EasyAsk/Search.



When I try to invoke EasyAskImplRemoteFactory, I get a class does not exist error. I know the lib files are not autoloaded as I don't see them referenced in vendor/composer/autoload_namespaces.php file.



Can somebody tell me what I'm doing wrong?



Here is the composer.json in my module




"name": "easyask/module-search",
"description": "A better search module from EasyAsk",
"require":
"php": "~5.5.0,
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"extra":
"map": [
[
"*",
"EasyAsk/Search"
]
]





Here is the composer.json from vendor/easyask/easyask_search directory




"name": "easyask/easyask_search",
"type": "magento2-library",
"description": "EasyAsk Search PHP Client Library",
"license": "N/A",
"authors": [

"name": "EasyAsk",
"homepage": "http://www.easyask.com"

],
"require":
"php": ">=5.2.1",
"ext-curl": "*",
"ext-dom": "*",
"ext-hash": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*"
,
"require-dev":
"phpunit/phpunit": "3.7.*"
,
"autoload":
"psr-0":
"EasyAsk": "lib"






Part of controller class where I'm trying to inject RemoteFactory



use MagentoFrameworkEventManager;
use EasyAskImplRemoteFactory;

class Index extends MagentoCatalogSearchControllerResultIndex
{
/**
* @var QueryFactory
*/
private $_queryFactory;

/**
* Catalog Layer Resolver
*
* @var Resolver
*/
private $layerResolver;

protected $scopeConfig;

protected $_eventManager;

protected $_remoteFactory;

/**
* @param Context $context
* @param Session $catalogSession
* @param StoreManagerInterface $storeManager
* @param QueryFactory $queryFactory
* @param Resolver $layerResolver
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
Context $context,
Session $catalogSession,
StoreManagerInterface $storeManager,
QueryFactory $queryFactory,
Resolver $layerResolver,
ScopeConfigInterface $scopeConfig,
Manager $eventManager,
RemoteFactory $remoteFactory
)
parent::__construct($context, $catalogSession, $storeManager, $queryFactory, $layerResolver);
$this->_storeManager = $storeManager;
$this->_catalogSession = $catalogSession;
$this->_queryFactory = $queryFactory;
$this->layerResolver = $layerResolver;
$this->scopeConfig = $scopeConfig;
$this->_eventManager = $eventManager;
$this->_remoteFactory = $remoteFactory;



Let me know if you need any more information.







magento2 composer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 25 '17 at 20:00









Rafael Corrêa Gomes

4,71523366




4,71523366










asked Feb 23 '16 at 17:22









SrinivasSrinivas

13




13












  • What version of 2.0 are you running (1.0.0-beta)? You should take a look at the latest 2.0.x version because there are some changes to composer.json. Also take a look at alankent.me/2015/10/13/…

    – Renon Stewart
    Feb 23 '16 at 17:29












  • I am using the beta version. Let me download the latest version and try it again. Thanks.

    – Srinivas
    Feb 23 '16 at 21:18











  • I downloaded 2.0.2, installed it, did all the upgrades, made sure the site is working as expected. Added my module and made sure the controller class is getting called. I tried psr-4 approach without any luck. Maybe my approach to this problem is wrong. Let me state what I am trying to do. I want somebody to comment on the correct approach. I have a module that has all the stuff (blocks, controller, models etc), in Magento 1 I had the library files (bunch of files that makes a curl request to a server and parse the JSON response into php objects) in lib directory. Based on my

    – Srinivas
    Feb 25 '16 at 20:55











  • understanding I tried to add the lib files in vendor. that did not work. After further reading I placed the files in <magento install dir>/lib. The structure is lib/easyask/easyask/lib/EasyAsk/Impl. I have composer.json file in lib/easyask/easyask directory that has "autoload": "psr-4": "EasyAsk\": "lib/" . Is this the right approach? BTW, this did not work either. When i did setup:di:compile, I get Class does not exist error for EasyAskImpleRemoteFactory. Should I just place the files in app/code/EasyAsk/lib directory?

    – Srinivas
    Feb 25 '16 at 21:02

















  • What version of 2.0 are you running (1.0.0-beta)? You should take a look at the latest 2.0.x version because there are some changes to composer.json. Also take a look at alankent.me/2015/10/13/…

    – Renon Stewart
    Feb 23 '16 at 17:29












  • I am using the beta version. Let me download the latest version and try it again. Thanks.

    – Srinivas
    Feb 23 '16 at 21:18











  • I downloaded 2.0.2, installed it, did all the upgrades, made sure the site is working as expected. Added my module and made sure the controller class is getting called. I tried psr-4 approach without any luck. Maybe my approach to this problem is wrong. Let me state what I am trying to do. I want somebody to comment on the correct approach. I have a module that has all the stuff (blocks, controller, models etc), in Magento 1 I had the library files (bunch of files that makes a curl request to a server and parse the JSON response into php objects) in lib directory. Based on my

    – Srinivas
    Feb 25 '16 at 20:55











  • understanding I tried to add the lib files in vendor. that did not work. After further reading I placed the files in <magento install dir>/lib. The structure is lib/easyask/easyask/lib/EasyAsk/Impl. I have composer.json file in lib/easyask/easyask directory that has "autoload": "psr-4": "EasyAsk\": "lib/" . Is this the right approach? BTW, this did not work either. When i did setup:di:compile, I get Class does not exist error for EasyAskImpleRemoteFactory. Should I just place the files in app/code/EasyAsk/lib directory?

    – Srinivas
    Feb 25 '16 at 21:02
















What version of 2.0 are you running (1.0.0-beta)? You should take a look at the latest 2.0.x version because there are some changes to composer.json. Also take a look at alankent.me/2015/10/13/…

– Renon Stewart
Feb 23 '16 at 17:29






What version of 2.0 are you running (1.0.0-beta)? You should take a look at the latest 2.0.x version because there are some changes to composer.json. Also take a look at alankent.me/2015/10/13/…

– Renon Stewart
Feb 23 '16 at 17:29














I am using the beta version. Let me download the latest version and try it again. Thanks.

– Srinivas
Feb 23 '16 at 21:18





I am using the beta version. Let me download the latest version and try it again. Thanks.

– Srinivas
Feb 23 '16 at 21:18













I downloaded 2.0.2, installed it, did all the upgrades, made sure the site is working as expected. Added my module and made sure the controller class is getting called. I tried psr-4 approach without any luck. Maybe my approach to this problem is wrong. Let me state what I am trying to do. I want somebody to comment on the correct approach. I have a module that has all the stuff (blocks, controller, models etc), in Magento 1 I had the library files (bunch of files that makes a curl request to a server and parse the JSON response into php objects) in lib directory. Based on my

– Srinivas
Feb 25 '16 at 20:55





I downloaded 2.0.2, installed it, did all the upgrades, made sure the site is working as expected. Added my module and made sure the controller class is getting called. I tried psr-4 approach without any luck. Maybe my approach to this problem is wrong. Let me state what I am trying to do. I want somebody to comment on the correct approach. I have a module that has all the stuff (blocks, controller, models etc), in Magento 1 I had the library files (bunch of files that makes a curl request to a server and parse the JSON response into php objects) in lib directory. Based on my

– Srinivas
Feb 25 '16 at 20:55













understanding I tried to add the lib files in vendor. that did not work. After further reading I placed the files in <magento install dir>/lib. The structure is lib/easyask/easyask/lib/EasyAsk/Impl. I have composer.json file in lib/easyask/easyask directory that has "autoload": "psr-4": "EasyAsk\": "lib/" . Is this the right approach? BTW, this did not work either. When i did setup:di:compile, I get Class does not exist error for EasyAskImpleRemoteFactory. Should I just place the files in app/code/EasyAsk/lib directory?

– Srinivas
Feb 25 '16 at 21:02





understanding I tried to add the lib files in vendor. that did not work. After further reading I placed the files in <magento install dir>/lib. The structure is lib/easyask/easyask/lib/EasyAsk/Impl. I have composer.json file in lib/easyask/easyask directory that has "autoload": "psr-4": "EasyAsk\": "lib/" . Is this the right approach? BTW, this did not work either. When i did setup:di:compile, I get Class does not exist error for EasyAskImpleRemoteFactory. Should I just place the files in app/code/EasyAsk/lib directory?

– Srinivas
Feb 25 '16 at 21:02










2 Answers
2






active

oldest

votes


















0














if you installed the library via composer, I can only see one potential problem on first sight.



the psr-0 namespace declaration must have (I think) a trailing backslash (which also must be escaped). So it would look like this:



"psr-0": 
"EasyAsk\": "lib"



The file for the class in your library should then be located in lib/EasyAsk/Impl/RemoteFactory.php and have the namespace EasyAskImpl and the class name RemoteFactory



you could also leave out the type magento2-library then which would default to the library and just use the default composer autoloading mechanism.



you can find further information on composer psr-0 autoloading here: https://getcomposer.org/doc/04-schema.md#psr-0



to see if your library is correctly loaded via composer you can also look into the file vendor/composer/autoload_psr0.php (or smth similar). There should be an entry for this.



To recompile the composer autoloading files you can execute the following command in your Magento 2 root dir: composer dumpautoload






share|improve this answer

























  • Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

    – Srinivas
    Feb 23 '16 at 21:09











  • I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

    – stefandoorn
    Feb 23 '16 at 22:58











  • @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

    – stefandoorn
    Feb 23 '16 at 23:01











  • @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

    – Srinivas
    Feb 24 '16 at 18:22











  • using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

    – David Verholen
    Feb 24 '16 at 18:22


















0














Take a look how Magento 2 itself did this in Magento_Base modules' composer.json, inside extra key. I was able to utilise the same syntax for a php library in one of my modules. For reference, I just pasted that chunk of code below:



"extra": 
"component_paths":
"trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
"components/jquery": [
"lib/web/jquery.js",
"lib/web/jquery/jquery.min.js",
"lib/web/jquery/jquery-migrate.js"
],
"blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
"components/jqueryui": "lib/web/jquery/jquery-ui.js",
"twbs/bootstrap": "lib/web/jquery/jquery.tabs.js",
"tinymce/tinymce": "lib/web/tiny_mce"
,
"map": [
[
".htaccess",
".htaccess"
],
[
".htaccess.sample",
".htaccess.sample"
],
[
".php_cs",
".php_cs"
],
[
".travis.yml",
".travis.yml"
],
[
".user.ini",
".user.ini"
],
[
"CHANGELOG.md",
"CHANGELOG.md"
],
[
"CONTRIBUTING.md",
"CONTRIBUTING.md"
],
[
"COPYING.txt",
"COPYING.txt"
],
[
"Gruntfile.js.sample",
"Gruntfile.js.sample"
],
[
"ISSUE_TEMPLATE.md",
"ISSUE_TEMPLATE.md"
],
[
"LICENSE.txt",
"LICENSE.txt"
],
[
"LICENSE_AFL.txt",
"LICENSE_AFL.txt"
],
[
"app/.htaccess",
"app/.htaccess"
],
[
"app/autoload.php",
"app/autoload.php"
],
[
"app/bootstrap.php",
"app/bootstrap.php"
],
[
"app/design/adminhtml/Magento",
"app/design/adminhtml/Magento"
],
[
"app/design/frontend/Magento",
"app/design/frontend/Magento"
],
[
"app/etc/NonComposerComponentRegistration.php",
"app/etc/NonComposerComponentRegistration.php"
],
[
"app/etc/di.xml",
"app/etc/di.xml"
],
[
"app/functions.php",
"app/functions.php"
],
[
"bin/.htaccess",
"bin/.htaccess"
],
[
"bin/magento",
"bin/magento"
],
[
"dev/.htaccess",
"dev/.htaccess"
],
[
"dev/tests/api-functional/.gitignore",
"dev/tests/api-functional/.gitignore"
],
[
"dev/tests/api-functional/_files",
"dev/tests/api-functional/_files"
],
[
"dev/tests/api-functional/config",
"dev/tests/api-functional/config"
],
[
"dev/tests/api-functional/framework",
"dev/tests/api-functional/framework"
],
[
"dev/tests/api-functional/phpunit.xml.dist",
"dev/tests/api-functional/phpunit.xml.dist"
],
[
"dev/tests/api-functional/testsuite/Magento",
"dev/tests/api-functional/testsuite/Magento"
],
[
"dev/tests/functional/.gitignore",
"dev/tests/functional/.gitignore"
],
[
"dev/tests/functional/.htaccess.sample",
"dev/tests/functional/.htaccess.sample"
],
[
"dev/tests/functional/bootstrap.php",
"dev/tests/functional/bootstrap.php"
],
[
"dev/tests/functional/composer.json",
"dev/tests/functional/composer.json"
],
[
"dev/tests/functional/credentials.xml.dist",
"dev/tests/functional/credentials.xml.dist"
],
[
"dev/tests/functional/etc",
"dev/tests/functional/etc"
],
[
"dev/tests/functional/isolation.php",
"dev/tests/functional/isolation.php"
],
[
"dev/tests/functional/lib",
"dev/tests/functional/lib"
],
[
"dev/tests/functional/phpunit.xml.dist",
"dev/tests/functional/phpunit.xml.dist"
],
[
"dev/tests/functional/tests",
"dev/tests/functional/tests"
],
[
"dev/tests/functional/testsuites/Magento",
"dev/tests/functional/testsuites/Magento"
],
[
"dev/tests/functional/utils",
"dev/tests/functional/utils"
],
[
"dev/tests/integration/.gitignore",
"dev/tests/integration/.gitignore"
],
[
"dev/tests/integration/etc",
"dev/tests/integration/etc"
],
[
"dev/tests/integration/framework",
"dev/tests/integration/framework"
],
[
"dev/tests/integration/phpunit.xml.dist",
"dev/tests/integration/phpunit.xml.dist"
],
[
"dev/tests/integration/testsuite/Magento",
"dev/tests/integration/testsuite/Magento"
],
[
"dev/tests/integration/tmp",
"dev/tests/integration/tmp"
],
[
"dev/tests/js/JsTestDriver/.gitignore",
"dev/tests/js/JsTestDriver/.gitignore"
],
[
"dev/tests/js/JsTestDriver/framework",
"dev/tests/js/JsTestDriver/framework"
],
[
"dev/tests/js/JsTestDriver/jsTestDriver.php.dist",
"dev/tests/js/JsTestDriver/jsTestDriver.php.dist"
],
[
"dev/tests/js/JsTestDriver/jsTestDriverOrder.php",
"dev/tests/js/JsTestDriver/jsTestDriverOrder.php"
],
[
"dev/tests/js/JsTestDriver/run_js_tests.php",
"dev/tests/js/JsTestDriver/run_js_tests.php"
],
[
"dev/tests/js/JsTestDriver/testsuite/lib",
"dev/tests/js/JsTestDriver/testsuite/lib"
],
[
"dev/tests/js/JsTestDriver/testsuite/mage",
"dev/tests/js/JsTestDriver/testsuite/mage"
],
[
"dev/tests/js/jasmine",
"dev/tests/js/jasmine"
],
[
"dev/tests/static/.gitignore",
"dev/tests/static/.gitignore"
],
[
"dev/tests/static/framework",
"dev/tests/static/framework"
],
[
"dev/tests/static/get_github_changes.php",
"dev/tests/static/get_github_changes.php"
],
[
"dev/tests/static/phpunit-all.xml.dist",
"dev/tests/static/phpunit-all.xml.dist"
],
[
"dev/tests/static/phpunit.xml.dist",
"dev/tests/static/phpunit.xml.dist"
],
[
"dev/tests/static/testsuite/Magento",
"dev/tests/static/testsuite/Magento"
],
[
"dev/tests/unit/.gitignore",
"dev/tests/unit/.gitignore"
],
[
"dev/tests/unit/framework",
"dev/tests/unit/framework"
],
[
"dev/tests/unit/phpunit.xml.dist",
"dev/tests/unit/phpunit.xml.dist"
],
[
"dev/tests/unit/tmp",
"dev/tests/unit/tmp"
],
[
"dev/tools",
"dev/tools"
],
[
"dev/travis",
"dev/travis"
],
[
"index.php",
"index.php"
],
[
"lib/.htaccess",
"lib/.htaccess"
],
[
"lib/internal/LinLibertineFont",
"lib/internal/LinLibertineFont"
],
[
"lib/web/FormData.js",
"lib/web/FormData.js"
],
[
"lib/web/MutationObserver.js",
"lib/web/MutationObserver.js"
],
[
"lib/web/blank.html",
"lib/web/blank.html"
],
[
"lib/web/css",
"lib/web/css"
],
[
"lib/web/es6-collections.js",
"lib/web/es6-collections.js"
],
[
"lib/web/extjs",
"lib/web/extjs"
],
[
"lib/web/fonts",
"lib/web/fonts"
],
[
"lib/web/fotorama",
"lib/web/fotorama"
],
[
"lib/web/i18n",
"lib/web/i18n"
],
[
"lib/web/images",
"lib/web/images"
],
[
"lib/web/jquery.js",
"lib/web/jquery.js"
],
[
"lib/web/jquery",
"lib/web/jquery"
],
[
"lib/web/knockoutjs",
"lib/web/knockoutjs"
],
[
"lib/web/legacy-build.min.js",
"lib/web/legacy-build.min.js"
],
[
"lib/web/less",
"lib/web/less"
],
[
"lib/web/lib",
"lib/web/lib"
],
[
"lib/web/mage",
"lib/web/mage"
],
[
"lib/web/magnifier",
"lib/web/magnifier"
],
[
"lib/web/matchMedia.js",
"lib/web/matchMedia.js"
],
[
"lib/web/modernizr",
"lib/web/modernizr"
],
[
"lib/web/moment-timezone-with-data.js",
"lib/web/moment-timezone-with-data.js"
],
[
"lib/web/moment.js",
"lib/web/moment.js"
],
[
"lib/web/prototype",
"lib/web/prototype"
],
[
"lib/web/requirejs",
"lib/web/requirejs"
],
[
"lib/web/scriptaculous",
"lib/web/scriptaculous"
],
[
"lib/web/spacer.gif",
"lib/web/spacer.gif"
],
[
"lib/web/tiny_mce",
"lib/web/tiny_mce"
],
[
"lib/web/underscore.js",
"lib/web/underscore.js"
],
[
"lib/web/varien",
"lib/web/varien"
],
[
"nginx.conf.sample",
"nginx.conf.sample"
],
[
"package.json.sample",
"package.json.sample"
],
[
"php.ini.sample",
"php.ini.sample"
],
[
"phpserver",
"phpserver"
],
[
"pub/.htaccess",
"pub/.htaccess"
],
[
"pub/.user.ini",
"pub/.user.ini"
],
[
"pub/cron.php",
"pub/cron.php"
],
[
"pub/errors",
"pub/errors"
],
[
"pub/get.php",
"pub/get.php"
],
[
"pub/index.php",
"pub/index.php"
],
[
"pub/media/.htaccess",
"pub/media/.htaccess"
],
[
"pub/media/customer/.htaccess",
"pub/media/customer/.htaccess"
],
[
"pub/media/downloadable/.htaccess",
"pub/media/downloadable/.htaccess"
],
[
"pub/media/import",
"pub/media/import"
],
[
"pub/media/theme_customization/.htaccess",
"pub/media/theme_customization/.htaccess"
],
[
"pub/opt",
"pub/opt"
],
[
"pub/static.php",
"pub/static.php"
],
[
"pub/static/.htaccess",
"pub/static/.htaccess"
],
[
"setup",
"setup"
],
[
"var/.htaccess",
"var/.htaccess"
],
[
"vendor/.htaccess",
"vendor/.htaccess"
]
]



Hope this helps.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103094%2fmagento-2-cannot-load-my-library-using-composer%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    if you installed the library via composer, I can only see one potential problem on first sight.



    the psr-0 namespace declaration must have (I think) a trailing backslash (which also must be escaped). So it would look like this:



    "psr-0": 
    "EasyAsk\": "lib"



    The file for the class in your library should then be located in lib/EasyAsk/Impl/RemoteFactory.php and have the namespace EasyAskImpl and the class name RemoteFactory



    you could also leave out the type magento2-library then which would default to the library and just use the default composer autoloading mechanism.



    you can find further information on composer psr-0 autoloading here: https://getcomposer.org/doc/04-schema.md#psr-0



    to see if your library is correctly loaded via composer you can also look into the file vendor/composer/autoload_psr0.php (or smth similar). There should be an entry for this.



    To recompile the composer autoloading files you can execute the following command in your Magento 2 root dir: composer dumpautoload






    share|improve this answer

























    • Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

      – Srinivas
      Feb 23 '16 at 21:09











    • I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

      – stefandoorn
      Feb 23 '16 at 22:58











    • @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

      – stefandoorn
      Feb 23 '16 at 23:01











    • @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

      – Srinivas
      Feb 24 '16 at 18:22











    • using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

      – David Verholen
      Feb 24 '16 at 18:22















    0














    if you installed the library via composer, I can only see one potential problem on first sight.



    the psr-0 namespace declaration must have (I think) a trailing backslash (which also must be escaped). So it would look like this:



    "psr-0": 
    "EasyAsk\": "lib"



    The file for the class in your library should then be located in lib/EasyAsk/Impl/RemoteFactory.php and have the namespace EasyAskImpl and the class name RemoteFactory



    you could also leave out the type magento2-library then which would default to the library and just use the default composer autoloading mechanism.



    you can find further information on composer psr-0 autoloading here: https://getcomposer.org/doc/04-schema.md#psr-0



    to see if your library is correctly loaded via composer you can also look into the file vendor/composer/autoload_psr0.php (or smth similar). There should be an entry for this.



    To recompile the composer autoloading files you can execute the following command in your Magento 2 root dir: composer dumpautoload






    share|improve this answer

























    • Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

      – Srinivas
      Feb 23 '16 at 21:09











    • I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

      – stefandoorn
      Feb 23 '16 at 22:58











    • @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

      – stefandoorn
      Feb 23 '16 at 23:01











    • @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

      – Srinivas
      Feb 24 '16 at 18:22











    • using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

      – David Verholen
      Feb 24 '16 at 18:22













    0












    0








    0







    if you installed the library via composer, I can only see one potential problem on first sight.



    the psr-0 namespace declaration must have (I think) a trailing backslash (which also must be escaped). So it would look like this:



    "psr-0": 
    "EasyAsk\": "lib"



    The file for the class in your library should then be located in lib/EasyAsk/Impl/RemoteFactory.php and have the namespace EasyAskImpl and the class name RemoteFactory



    you could also leave out the type magento2-library then which would default to the library and just use the default composer autoloading mechanism.



    you can find further information on composer psr-0 autoloading here: https://getcomposer.org/doc/04-schema.md#psr-0



    to see if your library is correctly loaded via composer you can also look into the file vendor/composer/autoload_psr0.php (or smth similar). There should be an entry for this.



    To recompile the composer autoloading files you can execute the following command in your Magento 2 root dir: composer dumpautoload






    share|improve this answer















    if you installed the library via composer, I can only see one potential problem on first sight.



    the psr-0 namespace declaration must have (I think) a trailing backslash (which also must be escaped). So it would look like this:



    "psr-0": 
    "EasyAsk\": "lib"



    The file for the class in your library should then be located in lib/EasyAsk/Impl/RemoteFactory.php and have the namespace EasyAskImpl and the class name RemoteFactory



    you could also leave out the type magento2-library then which would default to the library and just use the default composer autoloading mechanism.



    you can find further information on composer psr-0 autoloading here: https://getcomposer.org/doc/04-schema.md#psr-0



    to see if your library is correctly loaded via composer you can also look into the file vendor/composer/autoload_psr0.php (or smth similar). There should be an entry for this.



    To recompile the composer autoloading files you can execute the following command in your Magento 2 root dir: composer dumpautoload







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 25 '17 at 20:01









    Rafael Corrêa Gomes

    4,71523366




    4,71523366










    answered Feb 23 '16 at 17:46









    David VerholenDavid Verholen

    5,54611231




    5,54611231












    • Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

      – Srinivas
      Feb 23 '16 at 21:09











    • I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

      – stefandoorn
      Feb 23 '16 at 22:58











    • @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

      – stefandoorn
      Feb 23 '16 at 23:01











    • @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

      – Srinivas
      Feb 24 '16 at 18:22











    • using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

      – David Verholen
      Feb 24 '16 at 18:22

















    • Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

      – Srinivas
      Feb 23 '16 at 21:09











    • I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

      – stefandoorn
      Feb 23 '16 at 22:58











    • @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

      – stefandoorn
      Feb 23 '16 at 23:01











    • @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

      – Srinivas
      Feb 24 '16 at 18:22











    • using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

      – David Verholen
      Feb 24 '16 at 18:22
















    Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

    – Srinivas
    Feb 23 '16 at 21:09





    Thank you @david-verholen for the response. I made the change in the namespace declaration, but without any luck. I still don't see the entry in vendor/composer/autoload_namespaces.php.

    – Srinivas
    Feb 23 '16 at 21:09













    I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

    – stefandoorn
    Feb 23 '16 at 22:58





    I think the trailing backslash is required when using PSR4, not with PSR0: stackoverflow.com/a/21463602/616307.

    – stefandoorn
    Feb 23 '16 at 22:58













    @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

    – stefandoorn
    Feb 23 '16 at 23:01





    @Srinivas After making changes to your modules, make sure to update things. You can't just change it inside the vendor folder and expect it to work; therefore you need the composer dump-autoload command to recompile things as mentioned above. I would suggest to go with PSR4 anyway, in my opinion its easier to follow the paths when using it, and easier to make use of it in composer.json.

    – stefandoorn
    Feb 23 '16 at 23:01













    @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

    – Srinivas
    Feb 24 '16 at 18:22





    @stefandoorn Thanks for your suggestion, I changed it to psr4. Yes whenever I make any changes I have been doing composer dump-autoload. I feel I am making a very simple mistake in the code and it still is not working. Here are the changes I made:1. Changed the vendor directory to easyask/easyask. 2. composer.json in vendor/easyask/easyask has "autoload": "psr-4": "EasyAsk\": "lib/EasyAsk/" 3. I changed the reference in module composer.json to point to easyask/easyask. I don't see easyask reference in vendor/composer/autoload_psr4.php.

    – Srinivas
    Feb 24 '16 at 18:22













    using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

    – David Verholen
    Feb 24 '16 at 18:22





    using psr-4 is most likely the better and easier approach. Did you change your directory Structure in your lib as well? with psr-4 defined like in your psr-0 Example, the Classfile would have to be in the directory lib/Impl/RemoteFactory.php

    – David Verholen
    Feb 24 '16 at 18:22













    0














    Take a look how Magento 2 itself did this in Magento_Base modules' composer.json, inside extra key. I was able to utilise the same syntax for a php library in one of my modules. For reference, I just pasted that chunk of code below:



    "extra": 
    "component_paths":
    "trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
    "components/jquery": [
    "lib/web/jquery.js",
    "lib/web/jquery/jquery.min.js",
    "lib/web/jquery/jquery-migrate.js"
    ],
    "blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
    "components/jqueryui": "lib/web/jquery/jquery-ui.js",
    "twbs/bootstrap": "lib/web/jquery/jquery.tabs.js",
    "tinymce/tinymce": "lib/web/tiny_mce"
    ,
    "map": [
    [
    ".htaccess",
    ".htaccess"
    ],
    [
    ".htaccess.sample",
    ".htaccess.sample"
    ],
    [
    ".php_cs",
    ".php_cs"
    ],
    [
    ".travis.yml",
    ".travis.yml"
    ],
    [
    ".user.ini",
    ".user.ini"
    ],
    [
    "CHANGELOG.md",
    "CHANGELOG.md"
    ],
    [
    "CONTRIBUTING.md",
    "CONTRIBUTING.md"
    ],
    [
    "COPYING.txt",
    "COPYING.txt"
    ],
    [
    "Gruntfile.js.sample",
    "Gruntfile.js.sample"
    ],
    [
    "ISSUE_TEMPLATE.md",
    "ISSUE_TEMPLATE.md"
    ],
    [
    "LICENSE.txt",
    "LICENSE.txt"
    ],
    [
    "LICENSE_AFL.txt",
    "LICENSE_AFL.txt"
    ],
    [
    "app/.htaccess",
    "app/.htaccess"
    ],
    [
    "app/autoload.php",
    "app/autoload.php"
    ],
    [
    "app/bootstrap.php",
    "app/bootstrap.php"
    ],
    [
    "app/design/adminhtml/Magento",
    "app/design/adminhtml/Magento"
    ],
    [
    "app/design/frontend/Magento",
    "app/design/frontend/Magento"
    ],
    [
    "app/etc/NonComposerComponentRegistration.php",
    "app/etc/NonComposerComponentRegistration.php"
    ],
    [
    "app/etc/di.xml",
    "app/etc/di.xml"
    ],
    [
    "app/functions.php",
    "app/functions.php"
    ],
    [
    "bin/.htaccess",
    "bin/.htaccess"
    ],
    [
    "bin/magento",
    "bin/magento"
    ],
    [
    "dev/.htaccess",
    "dev/.htaccess"
    ],
    [
    "dev/tests/api-functional/.gitignore",
    "dev/tests/api-functional/.gitignore"
    ],
    [
    "dev/tests/api-functional/_files",
    "dev/tests/api-functional/_files"
    ],
    [
    "dev/tests/api-functional/config",
    "dev/tests/api-functional/config"
    ],
    [
    "dev/tests/api-functional/framework",
    "dev/tests/api-functional/framework"
    ],
    [
    "dev/tests/api-functional/phpunit.xml.dist",
    "dev/tests/api-functional/phpunit.xml.dist"
    ],
    [
    "dev/tests/api-functional/testsuite/Magento",
    "dev/tests/api-functional/testsuite/Magento"
    ],
    [
    "dev/tests/functional/.gitignore",
    "dev/tests/functional/.gitignore"
    ],
    [
    "dev/tests/functional/.htaccess.sample",
    "dev/tests/functional/.htaccess.sample"
    ],
    [
    "dev/tests/functional/bootstrap.php",
    "dev/tests/functional/bootstrap.php"
    ],
    [
    "dev/tests/functional/composer.json",
    "dev/tests/functional/composer.json"
    ],
    [
    "dev/tests/functional/credentials.xml.dist",
    "dev/tests/functional/credentials.xml.dist"
    ],
    [
    "dev/tests/functional/etc",
    "dev/tests/functional/etc"
    ],
    [
    "dev/tests/functional/isolation.php",
    "dev/tests/functional/isolation.php"
    ],
    [
    "dev/tests/functional/lib",
    "dev/tests/functional/lib"
    ],
    [
    "dev/tests/functional/phpunit.xml.dist",
    "dev/tests/functional/phpunit.xml.dist"
    ],
    [
    "dev/tests/functional/tests",
    "dev/tests/functional/tests"
    ],
    [
    "dev/tests/functional/testsuites/Magento",
    "dev/tests/functional/testsuites/Magento"
    ],
    [
    "dev/tests/functional/utils",
    "dev/tests/functional/utils"
    ],
    [
    "dev/tests/integration/.gitignore",
    "dev/tests/integration/.gitignore"
    ],
    [
    "dev/tests/integration/etc",
    "dev/tests/integration/etc"
    ],
    [
    "dev/tests/integration/framework",
    "dev/tests/integration/framework"
    ],
    [
    "dev/tests/integration/phpunit.xml.dist",
    "dev/tests/integration/phpunit.xml.dist"
    ],
    [
    "dev/tests/integration/testsuite/Magento",
    "dev/tests/integration/testsuite/Magento"
    ],
    [
    "dev/tests/integration/tmp",
    "dev/tests/integration/tmp"
    ],
    [
    "dev/tests/js/JsTestDriver/.gitignore",
    "dev/tests/js/JsTestDriver/.gitignore"
    ],
    [
    "dev/tests/js/JsTestDriver/framework",
    "dev/tests/js/JsTestDriver/framework"
    ],
    [
    "dev/tests/js/JsTestDriver/jsTestDriver.php.dist",
    "dev/tests/js/JsTestDriver/jsTestDriver.php.dist"
    ],
    [
    "dev/tests/js/JsTestDriver/jsTestDriverOrder.php",
    "dev/tests/js/JsTestDriver/jsTestDriverOrder.php"
    ],
    [
    "dev/tests/js/JsTestDriver/run_js_tests.php",
    "dev/tests/js/JsTestDriver/run_js_tests.php"
    ],
    [
    "dev/tests/js/JsTestDriver/testsuite/lib",
    "dev/tests/js/JsTestDriver/testsuite/lib"
    ],
    [
    "dev/tests/js/JsTestDriver/testsuite/mage",
    "dev/tests/js/JsTestDriver/testsuite/mage"
    ],
    [
    "dev/tests/js/jasmine",
    "dev/tests/js/jasmine"
    ],
    [
    "dev/tests/static/.gitignore",
    "dev/tests/static/.gitignore"
    ],
    [
    "dev/tests/static/framework",
    "dev/tests/static/framework"
    ],
    [
    "dev/tests/static/get_github_changes.php",
    "dev/tests/static/get_github_changes.php"
    ],
    [
    "dev/tests/static/phpunit-all.xml.dist",
    "dev/tests/static/phpunit-all.xml.dist"
    ],
    [
    "dev/tests/static/phpunit.xml.dist",
    "dev/tests/static/phpunit.xml.dist"
    ],
    [
    "dev/tests/static/testsuite/Magento",
    "dev/tests/static/testsuite/Magento"
    ],
    [
    "dev/tests/unit/.gitignore",
    "dev/tests/unit/.gitignore"
    ],
    [
    "dev/tests/unit/framework",
    "dev/tests/unit/framework"
    ],
    [
    "dev/tests/unit/phpunit.xml.dist",
    "dev/tests/unit/phpunit.xml.dist"
    ],
    [
    "dev/tests/unit/tmp",
    "dev/tests/unit/tmp"
    ],
    [
    "dev/tools",
    "dev/tools"
    ],
    [
    "dev/travis",
    "dev/travis"
    ],
    [
    "index.php",
    "index.php"
    ],
    [
    "lib/.htaccess",
    "lib/.htaccess"
    ],
    [
    "lib/internal/LinLibertineFont",
    "lib/internal/LinLibertineFont"
    ],
    [
    "lib/web/FormData.js",
    "lib/web/FormData.js"
    ],
    [
    "lib/web/MutationObserver.js",
    "lib/web/MutationObserver.js"
    ],
    [
    "lib/web/blank.html",
    "lib/web/blank.html"
    ],
    [
    "lib/web/css",
    "lib/web/css"
    ],
    [
    "lib/web/es6-collections.js",
    "lib/web/es6-collections.js"
    ],
    [
    "lib/web/extjs",
    "lib/web/extjs"
    ],
    [
    "lib/web/fonts",
    "lib/web/fonts"
    ],
    [
    "lib/web/fotorama",
    "lib/web/fotorama"
    ],
    [
    "lib/web/i18n",
    "lib/web/i18n"
    ],
    [
    "lib/web/images",
    "lib/web/images"
    ],
    [
    "lib/web/jquery.js",
    "lib/web/jquery.js"
    ],
    [
    "lib/web/jquery",
    "lib/web/jquery"
    ],
    [
    "lib/web/knockoutjs",
    "lib/web/knockoutjs"
    ],
    [
    "lib/web/legacy-build.min.js",
    "lib/web/legacy-build.min.js"
    ],
    [
    "lib/web/less",
    "lib/web/less"
    ],
    [
    "lib/web/lib",
    "lib/web/lib"
    ],
    [
    "lib/web/mage",
    "lib/web/mage"
    ],
    [
    "lib/web/magnifier",
    "lib/web/magnifier"
    ],
    [
    "lib/web/matchMedia.js",
    "lib/web/matchMedia.js"
    ],
    [
    "lib/web/modernizr",
    "lib/web/modernizr"
    ],
    [
    "lib/web/moment-timezone-with-data.js",
    "lib/web/moment-timezone-with-data.js"
    ],
    [
    "lib/web/moment.js",
    "lib/web/moment.js"
    ],
    [
    "lib/web/prototype",
    "lib/web/prototype"
    ],
    [
    "lib/web/requirejs",
    "lib/web/requirejs"
    ],
    [
    "lib/web/scriptaculous",
    "lib/web/scriptaculous"
    ],
    [
    "lib/web/spacer.gif",
    "lib/web/spacer.gif"
    ],
    [
    "lib/web/tiny_mce",
    "lib/web/tiny_mce"
    ],
    [
    "lib/web/underscore.js",
    "lib/web/underscore.js"
    ],
    [
    "lib/web/varien",
    "lib/web/varien"
    ],
    [
    "nginx.conf.sample",
    "nginx.conf.sample"
    ],
    [
    "package.json.sample",
    "package.json.sample"
    ],
    [
    "php.ini.sample",
    "php.ini.sample"
    ],
    [
    "phpserver",
    "phpserver"
    ],
    [
    "pub/.htaccess",
    "pub/.htaccess"
    ],
    [
    "pub/.user.ini",
    "pub/.user.ini"
    ],
    [
    "pub/cron.php",
    "pub/cron.php"
    ],
    [
    "pub/errors",
    "pub/errors"
    ],
    [
    "pub/get.php",
    "pub/get.php"
    ],
    [
    "pub/index.php",
    "pub/index.php"
    ],
    [
    "pub/media/.htaccess",
    "pub/media/.htaccess"
    ],
    [
    "pub/media/customer/.htaccess",
    "pub/media/customer/.htaccess"
    ],
    [
    "pub/media/downloadable/.htaccess",
    "pub/media/downloadable/.htaccess"
    ],
    [
    "pub/media/import",
    "pub/media/import"
    ],
    [
    "pub/media/theme_customization/.htaccess",
    "pub/media/theme_customization/.htaccess"
    ],
    [
    "pub/opt",
    "pub/opt"
    ],
    [
    "pub/static.php",
    "pub/static.php"
    ],
    [
    "pub/static/.htaccess",
    "pub/static/.htaccess"
    ],
    [
    "setup",
    "setup"
    ],
    [
    "var/.htaccess",
    "var/.htaccess"
    ],
    [
    "vendor/.htaccess",
    "vendor/.htaccess"
    ]
    ]



    Hope this helps.






    share|improve this answer



























      0














      Take a look how Magento 2 itself did this in Magento_Base modules' composer.json, inside extra key. I was able to utilise the same syntax for a php library in one of my modules. For reference, I just pasted that chunk of code below:



      "extra": 
      "component_paths":
      "trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
      "components/jquery": [
      "lib/web/jquery.js",
      "lib/web/jquery/jquery.min.js",
      "lib/web/jquery/jquery-migrate.js"
      ],
      "blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
      "components/jqueryui": "lib/web/jquery/jquery-ui.js",
      "twbs/bootstrap": "lib/web/jquery/jquery.tabs.js",
      "tinymce/tinymce": "lib/web/tiny_mce"
      ,
      "map": [
      [
      ".htaccess",
      ".htaccess"
      ],
      [
      ".htaccess.sample",
      ".htaccess.sample"
      ],
      [
      ".php_cs",
      ".php_cs"
      ],
      [
      ".travis.yml",
      ".travis.yml"
      ],
      [
      ".user.ini",
      ".user.ini"
      ],
      [
      "CHANGELOG.md",
      "CHANGELOG.md"
      ],
      [
      "CONTRIBUTING.md",
      "CONTRIBUTING.md"
      ],
      [
      "COPYING.txt",
      "COPYING.txt"
      ],
      [
      "Gruntfile.js.sample",
      "Gruntfile.js.sample"
      ],
      [
      "ISSUE_TEMPLATE.md",
      "ISSUE_TEMPLATE.md"
      ],
      [
      "LICENSE.txt",
      "LICENSE.txt"
      ],
      [
      "LICENSE_AFL.txt",
      "LICENSE_AFL.txt"
      ],
      [
      "app/.htaccess",
      "app/.htaccess"
      ],
      [
      "app/autoload.php",
      "app/autoload.php"
      ],
      [
      "app/bootstrap.php",
      "app/bootstrap.php"
      ],
      [
      "app/design/adminhtml/Magento",
      "app/design/adminhtml/Magento"
      ],
      [
      "app/design/frontend/Magento",
      "app/design/frontend/Magento"
      ],
      [
      "app/etc/NonComposerComponentRegistration.php",
      "app/etc/NonComposerComponentRegistration.php"
      ],
      [
      "app/etc/di.xml",
      "app/etc/di.xml"
      ],
      [
      "app/functions.php",
      "app/functions.php"
      ],
      [
      "bin/.htaccess",
      "bin/.htaccess"
      ],
      [
      "bin/magento",
      "bin/magento"
      ],
      [
      "dev/.htaccess",
      "dev/.htaccess"
      ],
      [
      "dev/tests/api-functional/.gitignore",
      "dev/tests/api-functional/.gitignore"
      ],
      [
      "dev/tests/api-functional/_files",
      "dev/tests/api-functional/_files"
      ],
      [
      "dev/tests/api-functional/config",
      "dev/tests/api-functional/config"
      ],
      [
      "dev/tests/api-functional/framework",
      "dev/tests/api-functional/framework"
      ],
      [
      "dev/tests/api-functional/phpunit.xml.dist",
      "dev/tests/api-functional/phpunit.xml.dist"
      ],
      [
      "dev/tests/api-functional/testsuite/Magento",
      "dev/tests/api-functional/testsuite/Magento"
      ],
      [
      "dev/tests/functional/.gitignore",
      "dev/tests/functional/.gitignore"
      ],
      [
      "dev/tests/functional/.htaccess.sample",
      "dev/tests/functional/.htaccess.sample"
      ],
      [
      "dev/tests/functional/bootstrap.php",
      "dev/tests/functional/bootstrap.php"
      ],
      [
      "dev/tests/functional/composer.json",
      "dev/tests/functional/composer.json"
      ],
      [
      "dev/tests/functional/credentials.xml.dist",
      "dev/tests/functional/credentials.xml.dist"
      ],
      [
      "dev/tests/functional/etc",
      "dev/tests/functional/etc"
      ],
      [
      "dev/tests/functional/isolation.php",
      "dev/tests/functional/isolation.php"
      ],
      [
      "dev/tests/functional/lib",
      "dev/tests/functional/lib"
      ],
      [
      "dev/tests/functional/phpunit.xml.dist",
      "dev/tests/functional/phpunit.xml.dist"
      ],
      [
      "dev/tests/functional/tests",
      "dev/tests/functional/tests"
      ],
      [
      "dev/tests/functional/testsuites/Magento",
      "dev/tests/functional/testsuites/Magento"
      ],
      [
      "dev/tests/functional/utils",
      "dev/tests/functional/utils"
      ],
      [
      "dev/tests/integration/.gitignore",
      "dev/tests/integration/.gitignore"
      ],
      [
      "dev/tests/integration/etc",
      "dev/tests/integration/etc"
      ],
      [
      "dev/tests/integration/framework",
      "dev/tests/integration/framework"
      ],
      [
      "dev/tests/integration/phpunit.xml.dist",
      "dev/tests/integration/phpunit.xml.dist"
      ],
      [
      "dev/tests/integration/testsuite/Magento",
      "dev/tests/integration/testsuite/Magento"
      ],
      [
      "dev/tests/integration/tmp",
      "dev/tests/integration/tmp"
      ],
      [
      "dev/tests/js/JsTestDriver/.gitignore",
      "dev/tests/js/JsTestDriver/.gitignore"
      ],
      [
      "dev/tests/js/JsTestDriver/framework",
      "dev/tests/js/JsTestDriver/framework"
      ],
      [
      "dev/tests/js/JsTestDriver/jsTestDriver.php.dist",
      "dev/tests/js/JsTestDriver/jsTestDriver.php.dist"
      ],
      [
      "dev/tests/js/JsTestDriver/jsTestDriverOrder.php",
      "dev/tests/js/JsTestDriver/jsTestDriverOrder.php"
      ],
      [
      "dev/tests/js/JsTestDriver/run_js_tests.php",
      "dev/tests/js/JsTestDriver/run_js_tests.php"
      ],
      [
      "dev/tests/js/JsTestDriver/testsuite/lib",
      "dev/tests/js/JsTestDriver/testsuite/lib"
      ],
      [
      "dev/tests/js/JsTestDriver/testsuite/mage",
      "dev/tests/js/JsTestDriver/testsuite/mage"
      ],
      [
      "dev/tests/js/jasmine",
      "dev/tests/js/jasmine"
      ],
      [
      "dev/tests/static/.gitignore",
      "dev/tests/static/.gitignore"
      ],
      [
      "dev/tests/static/framework",
      "dev/tests/static/framework"
      ],
      [
      "dev/tests/static/get_github_changes.php",
      "dev/tests/static/get_github_changes.php"
      ],
      [
      "dev/tests/static/phpunit-all.xml.dist",
      "dev/tests/static/phpunit-all.xml.dist"
      ],
      [
      "dev/tests/static/phpunit.xml.dist",
      "dev/tests/static/phpunit.xml.dist"
      ],
      [
      "dev/tests/static/testsuite/Magento",
      "dev/tests/static/testsuite/Magento"
      ],
      [
      "dev/tests/unit/.gitignore",
      "dev/tests/unit/.gitignore"
      ],
      [
      "dev/tests/unit/framework",
      "dev/tests/unit/framework"
      ],
      [
      "dev/tests/unit/phpunit.xml.dist",
      "dev/tests/unit/phpunit.xml.dist"
      ],
      [
      "dev/tests/unit/tmp",
      "dev/tests/unit/tmp"
      ],
      [
      "dev/tools",
      "dev/tools"
      ],
      [
      "dev/travis",
      "dev/travis"
      ],
      [
      "index.php",
      "index.php"
      ],
      [
      "lib/.htaccess",
      "lib/.htaccess"
      ],
      [
      "lib/internal/LinLibertineFont",
      "lib/internal/LinLibertineFont"
      ],
      [
      "lib/web/FormData.js",
      "lib/web/FormData.js"
      ],
      [
      "lib/web/MutationObserver.js",
      "lib/web/MutationObserver.js"
      ],
      [
      "lib/web/blank.html",
      "lib/web/blank.html"
      ],
      [
      "lib/web/css",
      "lib/web/css"
      ],
      [
      "lib/web/es6-collections.js",
      "lib/web/es6-collections.js"
      ],
      [
      "lib/web/extjs",
      "lib/web/extjs"
      ],
      [
      "lib/web/fonts",
      "lib/web/fonts"
      ],
      [
      "lib/web/fotorama",
      "lib/web/fotorama"
      ],
      [
      "lib/web/i18n",
      "lib/web/i18n"
      ],
      [
      "lib/web/images",
      "lib/web/images"
      ],
      [
      "lib/web/jquery.js",
      "lib/web/jquery.js"
      ],
      [
      "lib/web/jquery",
      "lib/web/jquery"
      ],
      [
      "lib/web/knockoutjs",
      "lib/web/knockoutjs"
      ],
      [
      "lib/web/legacy-build.min.js",
      "lib/web/legacy-build.min.js"
      ],
      [
      "lib/web/less",
      "lib/web/less"
      ],
      [
      "lib/web/lib",
      "lib/web/lib"
      ],
      [
      "lib/web/mage",
      "lib/web/mage"
      ],
      [
      "lib/web/magnifier",
      "lib/web/magnifier"
      ],
      [
      "lib/web/matchMedia.js",
      "lib/web/matchMedia.js"
      ],
      [
      "lib/web/modernizr",
      "lib/web/modernizr"
      ],
      [
      "lib/web/moment-timezone-with-data.js",
      "lib/web/moment-timezone-with-data.js"
      ],
      [
      "lib/web/moment.js",
      "lib/web/moment.js"
      ],
      [
      "lib/web/prototype",
      "lib/web/prototype"
      ],
      [
      "lib/web/requirejs",
      "lib/web/requirejs"
      ],
      [
      "lib/web/scriptaculous",
      "lib/web/scriptaculous"
      ],
      [
      "lib/web/spacer.gif",
      "lib/web/spacer.gif"
      ],
      [
      "lib/web/tiny_mce",
      "lib/web/tiny_mce"
      ],
      [
      "lib/web/underscore.js",
      "lib/web/underscore.js"
      ],
      [
      "lib/web/varien",
      "lib/web/varien"
      ],
      [
      "nginx.conf.sample",
      "nginx.conf.sample"
      ],
      [
      "package.json.sample",
      "package.json.sample"
      ],
      [
      "php.ini.sample",
      "php.ini.sample"
      ],
      [
      "phpserver",
      "phpserver"
      ],
      [
      "pub/.htaccess",
      "pub/.htaccess"
      ],
      [
      "pub/.user.ini",
      "pub/.user.ini"
      ],
      [
      "pub/cron.php",
      "pub/cron.php"
      ],
      [
      "pub/errors",
      "pub/errors"
      ],
      [
      "pub/get.php",
      "pub/get.php"
      ],
      [
      "pub/index.php",
      "pub/index.php"
      ],
      [
      "pub/media/.htaccess",
      "pub/media/.htaccess"
      ],
      [
      "pub/media/customer/.htaccess",
      "pub/media/customer/.htaccess"
      ],
      [
      "pub/media/downloadable/.htaccess",
      "pub/media/downloadable/.htaccess"
      ],
      [
      "pub/media/import",
      "pub/media/import"
      ],
      [
      "pub/media/theme_customization/.htaccess",
      "pub/media/theme_customization/.htaccess"
      ],
      [
      "pub/opt",
      "pub/opt"
      ],
      [
      "pub/static.php",
      "pub/static.php"
      ],
      [
      "pub/static/.htaccess",
      "pub/static/.htaccess"
      ],
      [
      "setup",
      "setup"
      ],
      [
      "var/.htaccess",
      "var/.htaccess"
      ],
      [
      "vendor/.htaccess",
      "vendor/.htaccess"
      ]
      ]



      Hope this helps.






      share|improve this answer

























        0












        0








        0







        Take a look how Magento 2 itself did this in Magento_Base modules' composer.json, inside extra key. I was able to utilise the same syntax for a php library in one of my modules. For reference, I just pasted that chunk of code below:



        "extra": 
        "component_paths":
        "trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
        "components/jquery": [
        "lib/web/jquery.js",
        "lib/web/jquery/jquery.min.js",
        "lib/web/jquery/jquery-migrate.js"
        ],
        "blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
        "components/jqueryui": "lib/web/jquery/jquery-ui.js",
        "twbs/bootstrap": "lib/web/jquery/jquery.tabs.js",
        "tinymce/tinymce": "lib/web/tiny_mce"
        ,
        "map": [
        [
        ".htaccess",
        ".htaccess"
        ],
        [
        ".htaccess.sample",
        ".htaccess.sample"
        ],
        [
        ".php_cs",
        ".php_cs"
        ],
        [
        ".travis.yml",
        ".travis.yml"
        ],
        [
        ".user.ini",
        ".user.ini"
        ],
        [
        "CHANGELOG.md",
        "CHANGELOG.md"
        ],
        [
        "CONTRIBUTING.md",
        "CONTRIBUTING.md"
        ],
        [
        "COPYING.txt",
        "COPYING.txt"
        ],
        [
        "Gruntfile.js.sample",
        "Gruntfile.js.sample"
        ],
        [
        "ISSUE_TEMPLATE.md",
        "ISSUE_TEMPLATE.md"
        ],
        [
        "LICENSE.txt",
        "LICENSE.txt"
        ],
        [
        "LICENSE_AFL.txt",
        "LICENSE_AFL.txt"
        ],
        [
        "app/.htaccess",
        "app/.htaccess"
        ],
        [
        "app/autoload.php",
        "app/autoload.php"
        ],
        [
        "app/bootstrap.php",
        "app/bootstrap.php"
        ],
        [
        "app/design/adminhtml/Magento",
        "app/design/adminhtml/Magento"
        ],
        [
        "app/design/frontend/Magento",
        "app/design/frontend/Magento"
        ],
        [
        "app/etc/NonComposerComponentRegistration.php",
        "app/etc/NonComposerComponentRegistration.php"
        ],
        [
        "app/etc/di.xml",
        "app/etc/di.xml"
        ],
        [
        "app/functions.php",
        "app/functions.php"
        ],
        [
        "bin/.htaccess",
        "bin/.htaccess"
        ],
        [
        "bin/magento",
        "bin/magento"
        ],
        [
        "dev/.htaccess",
        "dev/.htaccess"
        ],
        [
        "dev/tests/api-functional/.gitignore",
        "dev/tests/api-functional/.gitignore"
        ],
        [
        "dev/tests/api-functional/_files",
        "dev/tests/api-functional/_files"
        ],
        [
        "dev/tests/api-functional/config",
        "dev/tests/api-functional/config"
        ],
        [
        "dev/tests/api-functional/framework",
        "dev/tests/api-functional/framework"
        ],
        [
        "dev/tests/api-functional/phpunit.xml.dist",
        "dev/tests/api-functional/phpunit.xml.dist"
        ],
        [
        "dev/tests/api-functional/testsuite/Magento",
        "dev/tests/api-functional/testsuite/Magento"
        ],
        [
        "dev/tests/functional/.gitignore",
        "dev/tests/functional/.gitignore"
        ],
        [
        "dev/tests/functional/.htaccess.sample",
        "dev/tests/functional/.htaccess.sample"
        ],
        [
        "dev/tests/functional/bootstrap.php",
        "dev/tests/functional/bootstrap.php"
        ],
        [
        "dev/tests/functional/composer.json",
        "dev/tests/functional/composer.json"
        ],
        [
        "dev/tests/functional/credentials.xml.dist",
        "dev/tests/functional/credentials.xml.dist"
        ],
        [
        "dev/tests/functional/etc",
        "dev/tests/functional/etc"
        ],
        [
        "dev/tests/functional/isolation.php",
        "dev/tests/functional/isolation.php"
        ],
        [
        "dev/tests/functional/lib",
        "dev/tests/functional/lib"
        ],
        [
        "dev/tests/functional/phpunit.xml.dist",
        "dev/tests/functional/phpunit.xml.dist"
        ],
        [
        "dev/tests/functional/tests",
        "dev/tests/functional/tests"
        ],
        [
        "dev/tests/functional/testsuites/Magento",
        "dev/tests/functional/testsuites/Magento"
        ],
        [
        "dev/tests/functional/utils",
        "dev/tests/functional/utils"
        ],
        [
        "dev/tests/integration/.gitignore",
        "dev/tests/integration/.gitignore"
        ],
        [
        "dev/tests/integration/etc",
        "dev/tests/integration/etc"
        ],
        [
        "dev/tests/integration/framework",
        "dev/tests/integration/framework"
        ],
        [
        "dev/tests/integration/phpunit.xml.dist",
        "dev/tests/integration/phpunit.xml.dist"
        ],
        [
        "dev/tests/integration/testsuite/Magento",
        "dev/tests/integration/testsuite/Magento"
        ],
        [
        "dev/tests/integration/tmp",
        "dev/tests/integration/tmp"
        ],
        [
        "dev/tests/js/JsTestDriver/.gitignore",
        "dev/tests/js/JsTestDriver/.gitignore"
        ],
        [
        "dev/tests/js/JsTestDriver/framework",
        "dev/tests/js/JsTestDriver/framework"
        ],
        [
        "dev/tests/js/JsTestDriver/jsTestDriver.php.dist",
        "dev/tests/js/JsTestDriver/jsTestDriver.php.dist"
        ],
        [
        "dev/tests/js/JsTestDriver/jsTestDriverOrder.php",
        "dev/tests/js/JsTestDriver/jsTestDriverOrder.php"
        ],
        [
        "dev/tests/js/JsTestDriver/run_js_tests.php",
        "dev/tests/js/JsTestDriver/run_js_tests.php"
        ],
        [
        "dev/tests/js/JsTestDriver/testsuite/lib",
        "dev/tests/js/JsTestDriver/testsuite/lib"
        ],
        [
        "dev/tests/js/JsTestDriver/testsuite/mage",
        "dev/tests/js/JsTestDriver/testsuite/mage"
        ],
        [
        "dev/tests/js/jasmine",
        "dev/tests/js/jasmine"
        ],
        [
        "dev/tests/static/.gitignore",
        "dev/tests/static/.gitignore"
        ],
        [
        "dev/tests/static/framework",
        "dev/tests/static/framework"
        ],
        [
        "dev/tests/static/get_github_changes.php",
        "dev/tests/static/get_github_changes.php"
        ],
        [
        "dev/tests/static/phpunit-all.xml.dist",
        "dev/tests/static/phpunit-all.xml.dist"
        ],
        [
        "dev/tests/static/phpunit.xml.dist",
        "dev/tests/static/phpunit.xml.dist"
        ],
        [
        "dev/tests/static/testsuite/Magento",
        "dev/tests/static/testsuite/Magento"
        ],
        [
        "dev/tests/unit/.gitignore",
        "dev/tests/unit/.gitignore"
        ],
        [
        "dev/tests/unit/framework",
        "dev/tests/unit/framework"
        ],
        [
        "dev/tests/unit/phpunit.xml.dist",
        "dev/tests/unit/phpunit.xml.dist"
        ],
        [
        "dev/tests/unit/tmp",
        "dev/tests/unit/tmp"
        ],
        [
        "dev/tools",
        "dev/tools"
        ],
        [
        "dev/travis",
        "dev/travis"
        ],
        [
        "index.php",
        "index.php"
        ],
        [
        "lib/.htaccess",
        "lib/.htaccess"
        ],
        [
        "lib/internal/LinLibertineFont",
        "lib/internal/LinLibertineFont"
        ],
        [
        "lib/web/FormData.js",
        "lib/web/FormData.js"
        ],
        [
        "lib/web/MutationObserver.js",
        "lib/web/MutationObserver.js"
        ],
        [
        "lib/web/blank.html",
        "lib/web/blank.html"
        ],
        [
        "lib/web/css",
        "lib/web/css"
        ],
        [
        "lib/web/es6-collections.js",
        "lib/web/es6-collections.js"
        ],
        [
        "lib/web/extjs",
        "lib/web/extjs"
        ],
        [
        "lib/web/fonts",
        "lib/web/fonts"
        ],
        [
        "lib/web/fotorama",
        "lib/web/fotorama"
        ],
        [
        "lib/web/i18n",
        "lib/web/i18n"
        ],
        [
        "lib/web/images",
        "lib/web/images"
        ],
        [
        "lib/web/jquery.js",
        "lib/web/jquery.js"
        ],
        [
        "lib/web/jquery",
        "lib/web/jquery"
        ],
        [
        "lib/web/knockoutjs",
        "lib/web/knockoutjs"
        ],
        [
        "lib/web/legacy-build.min.js",
        "lib/web/legacy-build.min.js"
        ],
        [
        "lib/web/less",
        "lib/web/less"
        ],
        [
        "lib/web/lib",
        "lib/web/lib"
        ],
        [
        "lib/web/mage",
        "lib/web/mage"
        ],
        [
        "lib/web/magnifier",
        "lib/web/magnifier"
        ],
        [
        "lib/web/matchMedia.js",
        "lib/web/matchMedia.js"
        ],
        [
        "lib/web/modernizr",
        "lib/web/modernizr"
        ],
        [
        "lib/web/moment-timezone-with-data.js",
        "lib/web/moment-timezone-with-data.js"
        ],
        [
        "lib/web/moment.js",
        "lib/web/moment.js"
        ],
        [
        "lib/web/prototype",
        "lib/web/prototype"
        ],
        [
        "lib/web/requirejs",
        "lib/web/requirejs"
        ],
        [
        "lib/web/scriptaculous",
        "lib/web/scriptaculous"
        ],
        [
        "lib/web/spacer.gif",
        "lib/web/spacer.gif"
        ],
        [
        "lib/web/tiny_mce",
        "lib/web/tiny_mce"
        ],
        [
        "lib/web/underscore.js",
        "lib/web/underscore.js"
        ],
        [
        "lib/web/varien",
        "lib/web/varien"
        ],
        [
        "nginx.conf.sample",
        "nginx.conf.sample"
        ],
        [
        "package.json.sample",
        "package.json.sample"
        ],
        [
        "php.ini.sample",
        "php.ini.sample"
        ],
        [
        "phpserver",
        "phpserver"
        ],
        [
        "pub/.htaccess",
        "pub/.htaccess"
        ],
        [
        "pub/.user.ini",
        "pub/.user.ini"
        ],
        [
        "pub/cron.php",
        "pub/cron.php"
        ],
        [
        "pub/errors",
        "pub/errors"
        ],
        [
        "pub/get.php",
        "pub/get.php"
        ],
        [
        "pub/index.php",
        "pub/index.php"
        ],
        [
        "pub/media/.htaccess",
        "pub/media/.htaccess"
        ],
        [
        "pub/media/customer/.htaccess",
        "pub/media/customer/.htaccess"
        ],
        [
        "pub/media/downloadable/.htaccess",
        "pub/media/downloadable/.htaccess"
        ],
        [
        "pub/media/import",
        "pub/media/import"
        ],
        [
        "pub/media/theme_customization/.htaccess",
        "pub/media/theme_customization/.htaccess"
        ],
        [
        "pub/opt",
        "pub/opt"
        ],
        [
        "pub/static.php",
        "pub/static.php"
        ],
        [
        "pub/static/.htaccess",
        "pub/static/.htaccess"
        ],
        [
        "setup",
        "setup"
        ],
        [
        "var/.htaccess",
        "var/.htaccess"
        ],
        [
        "vendor/.htaccess",
        "vendor/.htaccess"
        ]
        ]



        Hope this helps.






        share|improve this answer













        Take a look how Magento 2 itself did this in Magento_Base modules' composer.json, inside extra key. I was able to utilise the same syntax for a php library in one of my modules. For reference, I just pasted that chunk of code below:



        "extra": 
        "component_paths":
        "trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
        "components/jquery": [
        "lib/web/jquery.js",
        "lib/web/jquery/jquery.min.js",
        "lib/web/jquery/jquery-migrate.js"
        ],
        "blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
        "components/jqueryui": "lib/web/jquery/jquery-ui.js",
        "twbs/bootstrap": "lib/web/jquery/jquery.tabs.js",
        "tinymce/tinymce": "lib/web/tiny_mce"
        ,
        "map": [
        [
        ".htaccess",
        ".htaccess"
        ],
        [
        ".htaccess.sample",
        ".htaccess.sample"
        ],
        [
        ".php_cs",
        ".php_cs"
        ],
        [
        ".travis.yml",
        ".travis.yml"
        ],
        [
        ".user.ini",
        ".user.ini"
        ],
        [
        "CHANGELOG.md",
        "CHANGELOG.md"
        ],
        [
        "CONTRIBUTING.md",
        "CONTRIBUTING.md"
        ],
        [
        "COPYING.txt",
        "COPYING.txt"
        ],
        [
        "Gruntfile.js.sample",
        "Gruntfile.js.sample"
        ],
        [
        "ISSUE_TEMPLATE.md",
        "ISSUE_TEMPLATE.md"
        ],
        [
        "LICENSE.txt",
        "LICENSE.txt"
        ],
        [
        "LICENSE_AFL.txt",
        "LICENSE_AFL.txt"
        ],
        [
        "app/.htaccess",
        "app/.htaccess"
        ],
        [
        "app/autoload.php",
        "app/autoload.php"
        ],
        [
        "app/bootstrap.php",
        "app/bootstrap.php"
        ],
        [
        "app/design/adminhtml/Magento",
        "app/design/adminhtml/Magento"
        ],
        [
        "app/design/frontend/Magento",
        "app/design/frontend/Magento"
        ],
        [
        "app/etc/NonComposerComponentRegistration.php",
        "app/etc/NonComposerComponentRegistration.php"
        ],
        [
        "app/etc/di.xml",
        "app/etc/di.xml"
        ],
        [
        "app/functions.php",
        "app/functions.php"
        ],
        [
        "bin/.htaccess",
        "bin/.htaccess"
        ],
        [
        "bin/magento",
        "bin/magento"
        ],
        [
        "dev/.htaccess",
        "dev/.htaccess"
        ],
        [
        "dev/tests/api-functional/.gitignore",
        "dev/tests/api-functional/.gitignore"
        ],
        [
        "dev/tests/api-functional/_files",
        "dev/tests/api-functional/_files"
        ],
        [
        "dev/tests/api-functional/config",
        "dev/tests/api-functional/config"
        ],
        [
        "dev/tests/api-functional/framework",
        "dev/tests/api-functional/framework"
        ],
        [
        "dev/tests/api-functional/phpunit.xml.dist",
        "dev/tests/api-functional/phpunit.xml.dist"
        ],
        [
        "dev/tests/api-functional/testsuite/Magento",
        "dev/tests/api-functional/testsuite/Magento"
        ],
        [
        "dev/tests/functional/.gitignore",
        "dev/tests/functional/.gitignore"
        ],
        [
        "dev/tests/functional/.htaccess.sample",
        "dev/tests/functional/.htaccess.sample"
        ],
        [
        "dev/tests/functional/bootstrap.php",
        "dev/tests/functional/bootstrap.php"
        ],
        [
        "dev/tests/functional/composer.json",
        "dev/tests/functional/composer.json"
        ],
        [
        "dev/tests/functional/credentials.xml.dist",
        "dev/tests/functional/credentials.xml.dist"
        ],
        [
        "dev/tests/functional/etc",
        "dev/tests/functional/etc"
        ],
        [
        "dev/tests/functional/isolation.php",
        "dev/tests/functional/isolation.php"
        ],
        [
        "dev/tests/functional/lib",
        "dev/tests/functional/lib"
        ],
        [
        "dev/tests/functional/phpunit.xml.dist",
        "dev/tests/functional/phpunit.xml.dist"
        ],
        [
        "dev/tests/functional/tests",
        "dev/tests/functional/tests"
        ],
        [
        "dev/tests/functional/testsuites/Magento",
        "dev/tests/functional/testsuites/Magento"
        ],
        [
        "dev/tests/functional/utils",
        "dev/tests/functional/utils"
        ],
        [
        "dev/tests/integration/.gitignore",
        "dev/tests/integration/.gitignore"
        ],
        [
        "dev/tests/integration/etc",
        "dev/tests/integration/etc"
        ],
        [
        "dev/tests/integration/framework",
        "dev/tests/integration/framework"
        ],
        [
        "dev/tests/integration/phpunit.xml.dist",
        "dev/tests/integration/phpunit.xml.dist"
        ],
        [
        "dev/tests/integration/testsuite/Magento",
        "dev/tests/integration/testsuite/Magento"
        ],
        [
        "dev/tests/integration/tmp",
        "dev/tests/integration/tmp"
        ],
        [
        "dev/tests/js/JsTestDriver/.gitignore",
        "dev/tests/js/JsTestDriver/.gitignore"
        ],
        [
        "dev/tests/js/JsTestDriver/framework",
        "dev/tests/js/JsTestDriver/framework"
        ],
        [
        "dev/tests/js/JsTestDriver/jsTestDriver.php.dist",
        "dev/tests/js/JsTestDriver/jsTestDriver.php.dist"
        ],
        [
        "dev/tests/js/JsTestDriver/jsTestDriverOrder.php",
        "dev/tests/js/JsTestDriver/jsTestDriverOrder.php"
        ],
        [
        "dev/tests/js/JsTestDriver/run_js_tests.php",
        "dev/tests/js/JsTestDriver/run_js_tests.php"
        ],
        [
        "dev/tests/js/JsTestDriver/testsuite/lib",
        "dev/tests/js/JsTestDriver/testsuite/lib"
        ],
        [
        "dev/tests/js/JsTestDriver/testsuite/mage",
        "dev/tests/js/JsTestDriver/testsuite/mage"
        ],
        [
        "dev/tests/js/jasmine",
        "dev/tests/js/jasmine"
        ],
        [
        "dev/tests/static/.gitignore",
        "dev/tests/static/.gitignore"
        ],
        [
        "dev/tests/static/framework",
        "dev/tests/static/framework"
        ],
        [
        "dev/tests/static/get_github_changes.php",
        "dev/tests/static/get_github_changes.php"
        ],
        [
        "dev/tests/static/phpunit-all.xml.dist",
        "dev/tests/static/phpunit-all.xml.dist"
        ],
        [
        "dev/tests/static/phpunit.xml.dist",
        "dev/tests/static/phpunit.xml.dist"
        ],
        [
        "dev/tests/static/testsuite/Magento",
        "dev/tests/static/testsuite/Magento"
        ],
        [
        "dev/tests/unit/.gitignore",
        "dev/tests/unit/.gitignore"
        ],
        [
        "dev/tests/unit/framework",
        "dev/tests/unit/framework"
        ],
        [
        "dev/tests/unit/phpunit.xml.dist",
        "dev/tests/unit/phpunit.xml.dist"
        ],
        [
        "dev/tests/unit/tmp",
        "dev/tests/unit/tmp"
        ],
        [
        "dev/tools",
        "dev/tools"
        ],
        [
        "dev/travis",
        "dev/travis"
        ],
        [
        "index.php",
        "index.php"
        ],
        [
        "lib/.htaccess",
        "lib/.htaccess"
        ],
        [
        "lib/internal/LinLibertineFont",
        "lib/internal/LinLibertineFont"
        ],
        [
        "lib/web/FormData.js",
        "lib/web/FormData.js"
        ],
        [
        "lib/web/MutationObserver.js",
        "lib/web/MutationObserver.js"
        ],
        [
        "lib/web/blank.html",
        "lib/web/blank.html"
        ],
        [
        "lib/web/css",
        "lib/web/css"
        ],
        [
        "lib/web/es6-collections.js",
        "lib/web/es6-collections.js"
        ],
        [
        "lib/web/extjs",
        "lib/web/extjs"
        ],
        [
        "lib/web/fonts",
        "lib/web/fonts"
        ],
        [
        "lib/web/fotorama",
        "lib/web/fotorama"
        ],
        [
        "lib/web/i18n",
        "lib/web/i18n"
        ],
        [
        "lib/web/images",
        "lib/web/images"
        ],
        [
        "lib/web/jquery.js",
        "lib/web/jquery.js"
        ],
        [
        "lib/web/jquery",
        "lib/web/jquery"
        ],
        [
        "lib/web/knockoutjs",
        "lib/web/knockoutjs"
        ],
        [
        "lib/web/legacy-build.min.js",
        "lib/web/legacy-build.min.js"
        ],
        [
        "lib/web/less",
        "lib/web/less"
        ],
        [
        "lib/web/lib",
        "lib/web/lib"
        ],
        [
        "lib/web/mage",
        "lib/web/mage"
        ],
        [
        "lib/web/magnifier",
        "lib/web/magnifier"
        ],
        [
        "lib/web/matchMedia.js",
        "lib/web/matchMedia.js"
        ],
        [
        "lib/web/modernizr",
        "lib/web/modernizr"
        ],
        [
        "lib/web/moment-timezone-with-data.js",
        "lib/web/moment-timezone-with-data.js"
        ],
        [
        "lib/web/moment.js",
        "lib/web/moment.js"
        ],
        [
        "lib/web/prototype",
        "lib/web/prototype"
        ],
        [
        "lib/web/requirejs",
        "lib/web/requirejs"
        ],
        [
        "lib/web/scriptaculous",
        "lib/web/scriptaculous"
        ],
        [
        "lib/web/spacer.gif",
        "lib/web/spacer.gif"
        ],
        [
        "lib/web/tiny_mce",
        "lib/web/tiny_mce"
        ],
        [
        "lib/web/underscore.js",
        "lib/web/underscore.js"
        ],
        [
        "lib/web/varien",
        "lib/web/varien"
        ],
        [
        "nginx.conf.sample",
        "nginx.conf.sample"
        ],
        [
        "package.json.sample",
        "package.json.sample"
        ],
        [
        "php.ini.sample",
        "php.ini.sample"
        ],
        [
        "phpserver",
        "phpserver"
        ],
        [
        "pub/.htaccess",
        "pub/.htaccess"
        ],
        [
        "pub/.user.ini",
        "pub/.user.ini"
        ],
        [
        "pub/cron.php",
        "pub/cron.php"
        ],
        [
        "pub/errors",
        "pub/errors"
        ],
        [
        "pub/get.php",
        "pub/get.php"
        ],
        [
        "pub/index.php",
        "pub/index.php"
        ],
        [
        "pub/media/.htaccess",
        "pub/media/.htaccess"
        ],
        [
        "pub/media/customer/.htaccess",
        "pub/media/customer/.htaccess"
        ],
        [
        "pub/media/downloadable/.htaccess",
        "pub/media/downloadable/.htaccess"
        ],
        [
        "pub/media/import",
        "pub/media/import"
        ],
        [
        "pub/media/theme_customization/.htaccess",
        "pub/media/theme_customization/.htaccess"
        ],
        [
        "pub/opt",
        "pub/opt"
        ],
        [
        "pub/static.php",
        "pub/static.php"
        ],
        [
        "pub/static/.htaccess",
        "pub/static/.htaccess"
        ],
        [
        "setup",
        "setup"
        ],
        [
        "var/.htaccess",
        "var/.htaccess"
        ],
        [
        "vendor/.htaccess",
        "vendor/.htaccess"
        ]
        ]



        Hope this helps.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 30 '17 at 17:08









        AsrarAsrar

        423311




        423311



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f103094%2fmagento-2-cannot-load-my-library-using-composer%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sum ergo cogito? 1 nng

            三茅街道4182Guuntc Dn precexpngmageondP