4

I want to add a particular plugin in my laravel app using composer. I don't want to sync whole of the plugins with composer.json, I just want to add a new plugin.

If I remove rest of the plugins and add a json value i.e. "mgallegos/laravel-jqgrid": "1.*", once the files are downloaded, all of the plugins get removed because they are not mentioned there in json file.

Can I only add 1 particular plugin without making any changes in rest of the plugins?

Here is what my json file looks like:

enter image description here

Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78

2 Answers2

4

To install particular package, use require command like this:

composer require vendor/package_name ~version

To update only single package, use update command:

composer update vendor/package_name

To update multiple packages at once:

composer update vendor/package_name vendor/package_name2

Options with update command:

  • --prefer-source: Install packages from source when available.
  • --prefer-dist: Install packages from dist when available.
  • --ignore-platform-reqs: ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these. See also the platform config option.
  • --dry-run: Simulate the command without actually doing anything.
  • --dev: Install packages listed in require-dev (this is the default behavior).
  • --no-dev: Skip installing packages listed in require-dev. The autoloader generation skips the autoload-dev rules.
  • --no-autoloader: Skips autoloader generation.
  • --no-scripts: Skips execution of scripts defined in composer.json.
  • --no-progress: Removes the progress display that can mess with some terminals or scripts which don't handle backspace characters.
  • --optimize-autoloader (-o): Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default.
  • --classmap-authoritative (-a): Autoload classes from the classmap only. Implicitly enables --optimize-autoloader.
  • --lock: Only updates the lock file hash to suppress warning about the lock file being out of date.
  • --with-dependencies: Add also all dependencies of whitelisted packages to the whitelist.
  • --root-reqs: Restricts the update to your first degree dependencies.
  • --prefer-stable: Prefer stable versions of dependencies.
  • --prefer-lowest: Prefer lowest versions of dependencies. Useful for testing minimal versions of requirements, generally used with --prefer-stable.

Reference: https://getcomposer.org/doc/03-cli.md

Alok Patel
  • 7,842
  • 5
  • 31
  • 47
3

Sure, you can add the new package to your composer.json and call composer install. This will not update your packages but only install the versions set in the composer.lock file and new packages.

Alternatively you can call composer require thenew/package ~1.0

Additional note: composer install will never update anything. If you have a composer.lock file and run composer install, composer will install the exact same version you had before. Only composer update will update to the latest version, matching your requested version-string.

Edit: It is recommended to don't touch the vendor directory at all. If you need to have a library changed: Fork it, change it, publish it under your namespace, so you can composer require it directly. This allows you to always recreate the same (working) vendor-directory with a composer install from scratch as long as your composer.json and composer.lock are intact.

tkausl
  • 13,686
  • 2
  • 33
  • 50
  • I have made some modification in one of my plugins, so won't be even updating or sync-ing them.. the second options seems good to me – Danyal Sandeelo Jun 27 '16 at 06:38
  • IIRC composer will not re-install existing packages, even if you modified them. But I recommend publishing the modified package under your namespace so you can just `require` your own version of it and don't need to redo all the changes when you need to re-install the packages (on a new host or something) – tkausl Jun 27 '16 at 06:40