R
R
Rishat Sultanov2017-03-25 20:40:01
Composer
Rishat Sultanov, 2017-03-25 20:40:01

How to properly add packages to the project?

Good afternoon, ladies and gentlemen.
In general, I can’t understand how to work with the dependency manager correctly. (Composer)
In my situation, I have a project that I often like to stick someone's package into.
But in the end, all the packages are updated for me and the package I need is also installed.
How can I install or update one package that I need without touching anything other than that package?
In my case, I'm using composer not globally. And for every project.
In composer.json
I have:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.4.*",
        "laravel/tinker": "~1.0",
        "tcg/voyager": "^0.11.3",
    "mcamara/laravel-localization": "1.2.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true
    }
}

When I install a new package I add it to reguire.
And I write composer update.
And all packages are updated.
Tried to remove already existing packages in reguire.
Composer starts removing these packages altogether.
composer install - answers me - nothing to install.
How to be in this situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2017-03-25
@rishatss

Worth doing composer require [--dev] packageName
https://getcomposer.org/doc/03-cli.md#require

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question