Symfony2 Composer Not Downloading Packages - symfony

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.

Related

Why composer updates all existent deps?

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/*

How to update a single library with Composer?

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

Symfony + Composer update history

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.

How can I install the Buzz bundle on Symfony 2.2.0?

I want to install the Buzz bundle. On GitHub, the installation instructions suggest the .bin/vendors install method. However, that's not supported in Symfony 2.2.0.
Is there another way I could install the bundle? I've been trying to install it using Composer, but without any luck.
Try adding in composer.json under require key:
"sensio/buzz-bundle": "dev-master"
Then follow the instructions from step3 onward
You'll also need to run composer.phar update after that.
And for future reference, lookup the package you need on packagist.org. You'll find there what you need to put in composer.json

Symfony 2.0 bundle installation

So I am a new to doctrine, but I am not able to install a bundle at all. I am following the guide, but the "error" which I am getting is very unusual.
Anyhow, I add this lines into deps file:
[FOSRestBundle]
git=http://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
Then I do:
./bin/vendors install
And I get:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Your project seems to be based on a Standard Edition that includes vendors.
Try to run ./bin/vendors install --reinstall
So on this standard way I am not able to install it at all. Can somebody explain me what is the problem, because to me it looks like, the symfony vendors script doesnt recognize changes in deps file at all.
This happens when you've downloaded the Symfony2 Standard Edition from the website. The vendor install script checks to see if the vendor directories are git repositories, and if not, will throw this error. You can fix the situation in one of two ways:
you can either run the command that it suggests: php bin/vendors install --reinstall
or, you can remove the vendors directory, then run php bin/vendors install, which amounts to about the same thing
No need to install that. Just follow the steps in the url : http://mmoreramerino.github.com/GearmanBundle/installation.html

Resources