Adding libraries using composer

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • bandtank
    replied
    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
    {
        ...
    }
    

    Leave a comment:


  • bandtank
    replied
    yuri How do you namespace this file? custom/Espo/Modules/TestModule/Test.php

    Is it 'namespace Espo\Custom\Modules\TestModule'?
    Last edited by bandtank; 07-10-2022, 07:46 PM.

    Leave a comment:


  • yuri
    replied
    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"
        }
    }
    The problem of such approach is when the library and Espo have mutual dependencies. You will need to make them ignored in the composer.json, so they won't installed.


    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.

    Leave a comment:


  • item
    replied
    look here .. emillod have make many video howto ..
    and how add library

    https://forum.espocrm.com/forum/deve...-do-you-think-

    Leave a comment:


  • bandtank
    started a topic Adding libraries using composer

    Adding libraries using composer

    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.
Working...