1

I'm trying to install some external JS libraries located in Github in a SF2 project with composer.json.

composer.json:

{
"name": "myproject",
"license": "my project",
"type": "project",
"description": "my project",
"autoload": {
    "psr-0": { "": "src/" }
},
"repositories": {
    "medium-editor" : {
        "type": "package",
        "package": {
            "name": "daviferreira/medium-editor",
            "type": "component",
            "version": "master",
            "source": {
                "url": "git://github.com/daviferreira/medium-editor.git",
                "type": "git",
                "reference": "master"
            },
            "extra": {
                "component": {
                    "scripts": [
                        "dist/js/medium-editor.min.js"
                    ],
                    "styles": [
                        "dist/css/medium-editor.min.css",
                        "dist/css/themes/*.min.css"
                    ]
                }
            },
            "require": {
                "robloach/component-installer": "*"
            }
        }
    },
    "classList" : {
        "type": "package",
        "package": {
            "name": "eligrey/classList.js",
            "type": "component",
            "version": "master",
            "source": {
                "url": "git://github.com/eligrey/classList.js.git",
                "type": "git",
                "reference": "master"
            },
            "extra": {
                "component": {
                    "scripts": [
                        "classList.min.js"
                    ]
                }
            },
            "require": {
                "robloach/component-installer": "*"
            }
        }
    }
},
"require": {
    ...

    "daviferreira/medium-editor" : "dev-master",
    "eligrey/classList.js" : "dev-master"
},
"require-dev": {
    "phpunit/phpunit": "3.7.*"
},    
"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
},
"config": {
    "bin-dir": "bin",
    "component-dir": "web/components"
},
"minimum-stability": "stable",
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "symlink",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.3-dev"
    }
}
}

The libraries are downloaded but... I'm expecting that composer will create, with the "robloach/component-installer" dependency, a copy of the files specified in "extra" of the "component" type package to the "web/component" directory, but it doesn't.

What's wrong with my config? Thanks!

3 Answers 3

3

After reading more carefully the robloach plugin documentation, I've tried again and finally found a solution. The problem was that I probably had made a lot of "composer update" with different configs and was obliged to remove / reinstall the packages to make it work! So the original config post in the question is the good one...

I put it again to be sure!

    "medium-editor" : {
        "type": "package",
        "package": {
            "require": {
                "robloach/component-installer": "*"
            },
            "name": "daviferreira/medium-editor",
            "type": "component",
            "version": "master",
            "source": {
                "url": "git://github.com/daviferreira/medium-editor.git",
                "type": "git",
                "reference": "master"
            },                
            "extra": {
                "component": {
                    "scripts": [
                        "dist/js/medium-editor.min.js"
                    ],
                    "styles": [
                        "dist/css/medium-editor.min.css",
                        "dist/css/themes/*.min.css"
                    ]
                }
            }
        }
    },

And for sure, don't forget to add the Robloach component in the "require" libraries:

        "robloach/component-installer": "dev-master",
Sign up to request clarification or add additional context in comments.

Comments

1

I would suggest to use bower for fetching frontend libraries. Composer was created for managing php libs dependencies. It is importand to separate this layers because it's the easiest solution to implement.

Comments

1

Try PHP Composer Asset Manager package with composer if the problem persist i think you should execute the command manualy:

app/console assets:install .

1 Comment

I've take a look on this package, and it's remind me that's the asset management is not a built-in composer functionnality. I already use a "component asset manager" which is github.com/RobLoach/component-installer. I've read more carefully the doc and found my mistake. Thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.