Add an external library to symfony

后端 未结 1 1613
感情败类
感情败类 2021-01-14 02:38

I\'m trying to add an external library to symfony. I\'ve tried this on the app/autoload.php:

$loader->add(\'LibCokeId\',__DIR__ . \'/../vendor/libcokeid/l         


        
1条回答
  •  抹茶落季
    2021-01-14 03:30

    In the situation where you have a library that doesn't use composer and you can't retrieve it from packagist, you can manipulate the Composer autoload.

    Simply add the class in the composer.json files, as example:

    "autoload": {
        "psr-0": { "": "src/" },
        "files": [
            "vendor/folder/my_custom_lib/myFiles.php",
            "vendor/libcokeid/libcokeid/lib/libCokeId/LibCokeId.php"
        ]
    },
    

    OR you can Autoload the whole folder in composer.json:

    "autoload": {
        "psr-0": { "": "src/" },
        "classmap": [
            "vendor/libcokeid/libcokeid/lib"
        ],
    },
    

    Remember to make a composer install after setting this.

    Hope this help.

    0 讨论(0)
提交回复
热议问题