I'm using composer to update symfony bundles,
after updating all bundles, I'm getting some errors and I'd like to restore the previous versions, the problem is that on my composer the version are like 2.*, so I don't know which version there where before.
Is there any composer history/log file where can I see the previous versions of all my bundles?
Thank you
look at composer.lock.
After installing the dependencies, Composer writes the list of the exact versions it installed into a composer.lock file. This locks the project to those specific versions.
http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
If you commit your composer.lock file (as you should), then if you have problems after an update you can just do git checkout composer.lock && composer install which will restore things to the way they were before.
Related
I'm working with a copy of Symfony (2.8.9) which works perfectly on my development server.
I've cloned the same repository that this server pulls from, down to my local, and updated composer / ran the Symfony installer. I started getting an error:
You have requested a synthetic service ("request").
I did a little research, and found that this is a bug in the next version of Symfony, 2.8.10, as reported here:
https://github.com/symfony/symfony/issues/19840
I will await the bug being fixed in 2.8.10, but in the meantime, I'd love to be able to downgrade from 2.8.10 to 2.8.9, so my local copy runs and matches the copy on my development server.
I've seen posts regarding changing the version numbers in composer.json, but all my numbers related to Symfony say "2.8", with the minor version number excluded. Additionally, my composer.json file matches on both my dev server and local.
Should I add the minor version number ".9" to the end of the composer.json dependencies, and install the dependencies with composer? Is it enough to add the minor version number to only Symfony-related dependencies, and have all other dependencies work correctly, or are there other version numbers that should be changed as well? Is my approach correct, or is there another way to do this entirely?
You can edit just one line in your composer.json:
"require": {
...
"symfony/symfony": "2.8.*, !=2.8.10",
...
This way, you tell Composer to avoid that specific version. All other dependencies will be retrieved automatically.
Important: you have to remove your composer.lock file first, as Composer will complain that you're locked to the very same version you're trying to avoid.
Disclaimer: backup and test first. I tested on a base Symfony install, not sure if other package will complain.
I added a new bundle dependency to my composer.json file and when running composer update command, the composer updates all existent deps while I just want to install the new bundle.
Is there a command option to install just the new deps without updating existent ones ?
Is there a command option to install just the new deps without updating existant ones?
Yes, there is: composer require.
Simply run composer require vendor/package.
From the docs
In order to get the latest versions of the dependencies and to update the composer.lock file, you should use the update command.
php composer.phar update
This will resolve all dependencies of the project and write the exact versions into composer.lock.
If you just want to update a few packages and not all, you can list them as such:
php composer.phar update vendor/package vendor/package2
You can also use wildcards to update a bunch of packages at once:
php composer.phar update vendor/*
When installing phpunit 4.0 using composer (in PHPStorm) I get ....
/phpunit
/sebastian
/symfony
Does anyone know why I get the 2nd two and if there are necessary in any way.
Thanks
these dependencies are necessary as you can see at the composer file of PHPUnit. Before Composer was around and they shipped the software only via PEAR, you need to install all the dependencies by your own. At the end nothing changed.
In case you are concerned about installing all these dependencies over and over again for every PHP project you need PHPUnit, you can install it globally on you system.
Add composer global require 'phpunit/phpunit=3.7.*' to your composer.json.
Yes, those two directories are necessary for PHPUnit to work.
The dependencies in the vendor folder are managed by composer for you, you don't need to worry here. The reason you have them is because you installed PHPUnit.
When you remove PHPUnit and those dependencies aren't required by any other package, they will be removed again.
I need to install only 1 package for my SF2 distribution (DoctrineFixtures).
When I run
php composer.phar update
I get
- Updating twig/twig (dev-master 39d94fa => v1.13.0)
The package has modified files:
M CHANGELOG
M doc/filters/batch.test
M doc/filters/index.rst
M doc/filters/url_encode.rst
M doc/functions/index.rst
M doc/tags/index.rst
M doc/tests/index.rst
M lib/Twig/Autoloader.php
M lib/Twig/Compiler.php
M lib/Twig/CompilerInterface.php
-10 more files modified, choose "v" to view the full list
It appears the last developer edited a lot of files inside vendor.
In order to get around this, I tried
php composer.phar update <package_name>
But that doesn't seem to work. How can I update/install only one library from composer.json?
To install doctrine/doctrine-fixtures-bundle with version 2.1.* and minimum stability #dev use this:
composer require doctrine/doctrine-fixtures-bundle:2.1.*#dev
then to update only this single package:
composer update doctrine/doctrine-fixtures-bundle
If you just want to update a few packages and not all, you can list them as such:
php composer.phar update vendor/package:2.* vendor/package2:dev-master
You can also use wildcards to update a bunch of packages at once:
php composer.phar update vendor/*
As commented by #ZeroThe2nd ZSH users may need to wrap their vendor/* in quotation marks:
php composer.phar update "vendor/*"
--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-plugins: Disables plugins.
--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.
--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.
--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.
Difference between install, update and require
Assume the following scenario:
composer.json
"parsecsv/php-parsecsv": "0.*"
composer.lock file
"name": "parsecsv/php-parsecsv",
"version": "0.1.4",
Latest release is 1.1.0. The latest 0.* release is 0.3.2
install: composer install parsecsv/php-parsecsv
This will install version 0.1.4 as specified in the lock file
update: composer update parsecsv/php-parsecsv
This will update the package to 0.3.2. The highest version with respect to your composer.json. The entry in composer.lock will be updated.
require: composer require parsecsv/php-parsecsv
This will update or install the newest version 1.1.0. Your composer.lock file and composer.json file will be updated as well.
You can use the following command to update any module with its dependencies
composer update vendor-name/module-name --with-dependencies
You can basically do following one to install new package as well.
php composer.phar require
then terminal will ask you to enter the name of the package for searching.
$ Search for a package []: //Your package name here
Then terminal will ask the version of the package (If you would like to have the latest version just leave it blank)
$ Enter the version constraint to require (or leave blank to use the latest version) []: //your version number here
Then you just press the return key. Terminal will ask for another package, if you dont want to install another one just press the return key and you will be done.
Just use
composer require {package/packagename}
like
composer require phpmailer/phpmailer
if the package is not in the vendor folder.. composer installs it and if the package exists, composer update package to the latest version.
Update:
require install or update the latest package version. if you want update one package just use update.
To ensure that composer update one package already installed to the last version within the version constraints you've set in composer.json remove the package from vendor and then execute :
php composer.phar update vendor/package
Because you wanted to install specific package
"I need to install only 1 package for my SF2 distribution (DoctrineFixtures)."
php composer.phar require package/package-name:package-version
would be enough
I was recently trying to re-install the fos:userbundle and noticed the docs have changed. They are no longer using the deps file are now referencing the new package manager composer.
I found some info about integrating composer with sf2.0.* here:
http://knplabs.com/blog/symfony2-with-composer
After downloading the src: https://github.com/KnpLabs/symfony-with-composer
I tried adding the following to my composer.json: "friendsofsymfony/user-bundle": "*"
as per the instructions: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md
When I run bin/vendors update I get the following:
Updating dependencies
Nothing to install or update
Writing lock file
Generating autoload files
It does not appear to be installing the fos package. Am I missing something?
Thanks
Composer is a PHAR archive that takes care of installing dependencies, update them, create projects, etc. It has nothing to do with the old bin/vendors.
What you need to do is to download Composer:
curl -s http://getcomposer.org/installer | php
And install your dependencies:
php composer.phar install
By the way, the symfony-with-composer thing you downloaded is an old version of Symfony2 Standard Distribution that isn't maintained anymore, as mentioned on the repository itself.