Composer installs jQuery components in wrong directory

后端 未结 1 1223
逝去的感伤
逝去的感伤 2020-12-18 04:43

I\'m trying to install jQuery components via Composer in CakePHP app, the composer.json:

{
    \"name\": \"affiliate\",
    \"require\": {
        \"cakephp/         


        
1条回答
  •  天涯浪人
    2020-12-18 05:14

    The components/jquery package uses component-installer, which can read from your composer.json a specified component-dir setting which is where you want to put the downloaded components - e.g. in your web/assets folder:

    {
        "require": {
            "components/jquery": "*"
        },
        "config": {
            "component-dir": "web/assets"
        }
    }
    

    To read more about this check out the docs here.

    You can then add those downloaded component files in web/assets to your .gitignore so that you're not adding files which are loaded in by the package manager.

    If you're not a fan of this approach, then one other option is that you can add your own package repository to your composer.json like this:

    {
        "repositories": [
            {
                "type": "package",
                "package": {
                    "name": "jquery/jquery",
                    "version": "2.1.1",
                    "dist": {
                        "url": "http://code.jquery.com/jquery-2.1.1.js",
                        "type": "file"
                    }
                }
            }
        ],
        "require": {
            "jquery/jquery": "2.1.1"
        }
    }
    

    With this approach, composer will download the JS file to vendor/jquery/jquery/jquery-2.1.1.js - you can then add a symlink to this from your www root directory.

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