Danish
Danish

Reputation: 353

how to stop composer from removing manually installed package

For some reason I'm unable to install Predis package in my project via composer require predis/predis, I have manually downloaded Predis package from https://php-download.com and moved predis folder to the vendor and then updated files inside vendor/composer, it works fine.

However, the problem is when I run composer dump-autoload, this command removes all references of this package from vendor/composer/autoload_psr4.php and autoload_static.php files.

Can someone please help me how can I prevent composer dump-autoload to remove references of this package?

Upvotes: 0

Views: 1340

Answers (2)

Danish
Danish

Reputation: 353

I fixed it by adding following code in vendor/composer/installed.json , I forgot to add it.

    {
    "name": "predis/predis",
    "version": "v1.1.1",
    "version_normalized": "1.1.1.0",
    "source": {
        "type": "git",
        "url": "https://github.com/nrk/predis.git",
        "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
        "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.8"
    },
    "suggest": {
        "ext-curl": "Allows access to Webdis when paired with phpiredis",
        "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
    },
    "time": "2016-06-16T16:22:20+00:00",
    "type": "library",
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Predis\\": "src/"
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Daniele Alessandri",
            "email": "[email protected]",
            "homepage": "http://clorophilla.net"
        }
    ],
    "description": "Flexible and feature-complete Redis client for PHP and HHVM",
    "homepage": "http://github.com/nrk/predis",
    "keywords": [
        "nosql",
        "predis",
        "redis"
    ]
}

Upvotes: 0

Rabah
Rabah

Reputation: 2062

Instead of copying your package to the vendor directory, you can use "repositories" in install a local package:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }
}

Upvotes: 3

Related Questions