Installing phpunit - are the sebastian & symfony directories necessary? - phpunit

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.

Related

Symfony 5 Phpunit undefined method

I'm working with Symfony 5 and I installed phpunit-bridge with the command included in the documentation : composer require --dev symfony/phpunit-bridge.
When I run phpunit with this command, php bin/phpunit, I have this error :
PHP Fatal error : Uncaught Error: Call to undefined method
PHPUnit\TextUI\TestRunner::doRun()
I'll try to guess.
You also have a bundle like liip/functional-test-bundle or other, which require PHPUnit in requirements (or even you require PHPUnit directly in your composer.json together with phpunit-bridge).
As a result you have two different version of PHPUnit installed in project, with two different api.
If installed liip/functional-test-bundle is your case and you do not want to remove it, you need to install by bridge same PHPUnit version as installed by Liip bundle dependency. You can set version through SYMFONY_PHPUNIT_VERSION env variable or directly in bin/phpunit file. Or you can redefine path to already installed PHPUnit version (in vendors/) through SYMFONY_PHPUNIT_DIR env or directly in bin/phpunit.
Note: you can not set SYMFONY_PHPUNIT_VERSION or SYMFONY_PHPUNIT_DIR through .env.* files, since bin/phpunit not read this files. So it should be real env vars.
I had a similar issue with symfony 5.1. I tried upgrading all dev packages related to testing but it didn't work.
Once I completely remove all dev (testing related) packages and reinstalling the symfony phpunit bridge package it worked.
You have to remove the phpunit file inside the root/bin directory
Steps to follow
Remove all dev test packages (Eg: composer remove symfony/browser-kit)
Remove if there are following packages : phpunit/phpunit, symfony/phpunit-bridge, symfony/css-selector, symfony/browser-kit
Install the brdge package again by running composer require --dev symfony/phpunit-bridge

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