Magento 2: Cannot load my library using composer The 2019 Stack Overflow Developer Survey...
Was credit for the black hole image misattributed?
In horse breeding, what is the female equivalent of putting a horse out "to stud"?
Are spiders unable to hurt humans, especially very small spiders?
The following signatures were invalid: EXPKEYSIG 1397BC53640DB551
Do warforged have souls?
How did passengers keep warm on sail ships?
Create an outline of font
Why is superheterodyning better than direct conversion?
How to copy the contents of all files with a certain name into a new file?
Can the DM override racial traits?
Segmentation fault output is suppressed when piping stdin into a function. Why?
Are my PIs rude or am I just being too sensitive?
Did God make two great lights or did He make the great light two?
Sort list of array linked objects by keys and values
Does the AirPods case need to be around while listening via an iOS Device?
How many people can fit inside Mordenkainen's Magnificent Mansion?
How do you keep chess fun when your opponent constantly beats you?
Grover's algorithm - DES circuit as oracle?
Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?
How to grep and cut numbes from a file and sum them
Empty set is subset of every set? If yes, why that...
A pet rabbit called Belle
how can a perfect fourth interval be considered either consonant or dissonant?
Who or what is the being for whom Being is a question for Heidegger?
Magento 2: Cannot load my library using composer
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)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 composerHow to solve Front controller reached 100 router match iterations in magento2PHP 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 found
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom: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|~5.6.0",
"magento/module-store": "1.0.0-beta",
"magento/module-catalog": "1.0.0-beta",
"magento/module-catalog-search": "1.0.0-beta",
"magento/module-backend": "1.0.0-beta",
"magento/module-theme": "1.0.0-beta",
"magento/framework": "1.0.0-beta",
"easyask/easyask_search": "2.0.0",
"magento/magento-composer-installer": "*"
},
"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
bumped to the homepage by Community♦ 14 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
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|~5.6.0",
"magento/module-store": "1.0.0-beta",
"magento/module-catalog": "1.0.0-beta",
"magento/module-catalog-search": "1.0.0-beta",
"magento/module-backend": "1.0.0-beta",
"magento/module-theme": "1.0.0-beta",
"magento/framework": "1.0.0-beta",
"easyask/easyask_search": "2.0.0",
"magento/magento-composer-installer": "*"
},
"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
bumped to the homepage by Community♦ 14 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
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
add a comment |
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|~5.6.0",
"magento/module-store": "1.0.0-beta",
"magento/module-catalog": "1.0.0-beta",
"magento/module-catalog-search": "1.0.0-beta",
"magento/module-backend": "1.0.0-beta",
"magento/module-theme": "1.0.0-beta",
"magento/framework": "1.0.0-beta",
"easyask/easyask_search": "2.0.0",
"magento/magento-composer-installer": "*"
},
"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
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|~5.6.0",
"magento/module-store": "1.0.0-beta",
"magento/module-catalog": "1.0.0-beta",
"magento/module-catalog-search": "1.0.0-beta",
"magento/module-backend": "1.0.0-beta",
"magento/module-theme": "1.0.0-beta",
"magento/framework": "1.0.0-beta",
"easyask/easyask_search": "2.0.0",
"magento/magento-composer-installer": "*"
},
"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
magento2 composer
edited Aug 25 '17 at 20:00
Rafael Corrêa Gomes
4,68523366
4,68523366
asked Feb 23 '16 at 17:22
SrinivasSrinivas
13
13
bumped to the homepage by Community♦ 14 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 14 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
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
|
show 6 more comments
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
|
show 6 more comments
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
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
|
show 6 more comments
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
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
edited Aug 25 '17 at 20:01
Rafael Corrêa Gomes
4,68523366
4,68523366
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
|
show 6 more comments
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
|
show 6 more comments
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.
add a comment |
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.
add a comment |
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.
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.
answered Sep 30 '17 at 17:08
AsrarAsrar
423311
423311
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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