11

I'm try using CakePHP for the first time with composer, but I have some problems.

I have this composer.json:

{
  "name": "example.com.br",
  "repositories": [
    {
      "type": "pear",
      "url": "http://pear.cakephp.org"
    }
  ],
  "config": {
    "vendor-dir": "Vendor/"
  },
  "require": {
    "php": ">=5.4",
    "pear-cakephp/cakephp": ">=2.4.3",
    "cakephp/debug_kit": "2.2.*",
    "smottt/wideimage": "dev-master"
  },
  "extra": {
    "installer-paths": {
      "app/Plugin/DebugKit": ["cakephp/debug_kit"],
      "app/Vendor/Wideimage": ["smottt/wideimage"]
    }
  }  
}

When I run composer install (or update) --prefer-dist, everything works except smottt/wideimage.

This package is being installed in the /Vendor folder instead /app/Vendor, so, installer-paths was ignored.

0

4 Answers 4

19

Of course, what Danack has said is true: the composer-installers plugin only supports a select list of package types.

In response to that, I have written an extension for the composer-installers plugin which allows any arbitrary package type to be handled by the "installer-paths" directive.

Simply require oomphinc/composer-installers-extender in your composer.json and add support for any additional arbitrary package types:

"extra": {
  "installer-types": ["library"],
  "installer-paths": {
    "special/package/": ["my/package"],
    "path/to/libraries/{$name}/": ["type:library"]
  }
}

For packages that don't specify a type, use the default type library.

3
  • 1
    Nice work, but if I put library, all package with type library are in the specified folder where I'd like the the one package to be in a specific folder.
    – pbonnefoi
    Mar 6, 2019 at 15:31
  • I also have the problem that the library type moves all vendors into a specific folder and custom types are ignored.
    – thaikolja
    Nov 17, 2019 at 12:53
  • Are you putting type:library in your config? I think that's expected to move all packages of that type. If you only want to change a specific package, then use the package name instead. That's shown in the "special/package/": ["my/package"] line in the answer.
    – Ian Dunn
    Dec 22, 2023 at 21:37
12

From the documentation.

You cannot use this to change the path of any package. This is only applicable to packages that require composer/installers and use a custom type that it handles.

From one of the packages you're installing:

{
    "name": "smottt/wideimage",
    "description": "An open-source PHP library for image manipulation. (With namespaces, PHP 5.3+)",
    "homepage": "http://wideimage.sourceforge.net",
    "type": "library",
    "license": ["GPL-2.0","LGPL-2.1"],
    "version": "11.02.19",
    "autoload": {
        "psr-0" : {
          "WideImage" : "lib/"
        }
    }
}

So basically the package you're trying to install doesn't support custom install paths.

0
6

Use option "script" of composer (work only with linux) :

"scripts": {
        "post-install-cmd": [
            "php -r \"system('mv '.getcwd().'/Vendor/smottt/wideimage '.getcwd().'/Vendor/Wideimage');\""
        ]
    }
1
  • 1
    This isn't elegant in any way but was the only way to get it installing into the correct dir for me.
    – Christian
    Sep 9, 2020 at 3:29
0

Add your custom types to the installer-types:

{
  "installer-types": ["library", "myttype-1", "mytype-2"]
}

https://packagist.org/packages/oomphinc/composer-installers-extender

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.