composer-phppackage

How to set custom folder path for sub folders in vendor when installing a package?


I want to install a package into my local project.For that I'm creating a composer.json file in my project folder is given below, it gives the total vendor folder of that package into my custom folder in my project. Its working fine.....

{
"config": {
        "vendor-dir": "/var/www/html/Test2/Testing/Down"
    },
}

It gives the package into 'Down' folder.

But, now I want the sub folders or files in that packages to be installed in my custom folders like js/css folders in my project.

For example i want jquery.js file into my local folder path

  /var/www/html/Test2/Testing/assests/js

From the package "frameworks/jquery".

For that, what changes are needed in my composer.json file?


Solution

  • I've modified my composer.json file, it looks like the below:

    {
    "config": {
            "vendor-dir": "/var/www/html/Test2/Testing/Down"
        },
    "require": {
    },
    "scripts": {
        "post-package-install": [
            "php -r \"exec('cp -r /var/www/html/Test2/Testing/Down/frameworks/jquery/* /var/www/html/Test2/Testing/assets/js');\""
        ]
    }
    }
    

    It will gives all selected files in a package to my local folder.

    Briefly the files in the folder 'frameworks/jquery' are copied into my local 'assets/js' folder.