Is there a way to add libraries to the vendor directory using composer? I need to use Stash in a custom service to prevent making a very slow call to a remote server. However, using composer to install a custom library doesn't seem to work. The autoloader breaks and I have to undo a number of changes.
Adding libraries using composer
Collapse
X
-
For Espo modules
1. Create a `composer.json` file with your dependencies. in your module root (`<application_or_custom>/Espo/Modules/{ModuleName}`).
2. Create a 'Resources/autoload.json' file in your module.
autoload.json:
Code:{ "psr-4": { "LibraryNamespace\\": "<application_or_custom>/Espo/Modules/{ModuleName}/vendor/<vendor-name>/<library-name>/path/to/src" } }
For those who build from the Espo repository (who don't make an installable extension, who don't use official Espo upgrades)
Just use "composer require". This will add dependencies to the main `vendor` directory.
Last edited by yuri; 06-19-2022, 08:07 AM.If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.Comment
-
In case anyone else needs to know, the answer to my question in the previous post is:
PHP Code:namespace Espo\Modules\<ModuleName>;
For example, a new class called Stuff in the Classes folder in a module called CalendarExt would be coded as follows:
PHP Code:<?php namespace Espo\Modules\CalendarExt\Classes; class Stuff { ... }
Comment
Comment