Why Composer require jquery installs unwanted PHP packages? - php

I just wanted jQuery and entered in the command line
composer require components/jquery ^1.11
But the log shows me:
Package operations: 4 installs, 0 updates, 0 removals
- Installing symfony/process (v3.2.7): Loading from cache
- Installing kriswallsmith/assetic (v1.4.0): Loading from cache
- Installing robloach/component-installer (0.2.3): Loading from cache
- Installing components/jquery (1.11.0): Loading from cache
Why does Composer install PHP related packages I never intended to install? And how do I get rid of the unwanted packages? Is there an better/cleaner install method?

you are trying to install on of 1.11 versions of a package, which is requires "robloach/component-installer" package to install , you can see that clearly here :
"require": {
"robloach/component-installer": "*"
},
however, robloach/component-installer requires some additional packages too,
also you can see that here
"require": {
"php": ">=5.3.2",
"kriswallsmith/assetic": "1.*",
"composer-plugin-api": "^1.0"
},

Related

Laravel "new project" installs a bunch of apps

I am completely new to Laravel.
I use Vagrant and virtual machine so I installed composer aand laravel installer there.
When I create new project each time I see that it also installs a bunch of other apps. It says
Crafting application... Loading composer repositories with package
information Installing dependencies (including require-dev) from lock
file Package operations: 70 installs, 0 updates, 0 removals
then goes a list of apps it installs
- Installing doctrine/inflector (v1.3.0): Loading from cache
- Installing doctrine/lexer (v1.0.1): Loading from cache
- Installing dragonmantank/cron-expression (v2.0.0): Loading from cache
- Installing erusev/parsedown (1.7.1): Loading from cache
- Installing vlucas/phpdotenv (v2.4.0): Loading from cache
- Installing symfony/css-selector (v4.0.6): Loading from cache
- Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache
- Installing symfony/polyfill-php72 (v1.7.0): Loading from cache
- Installing symfony/polyfill-mbstring (v1.7.0): Loading from cache
- Installing symfony/var-dumper (v4.0.6): Loading from cache
- Installing symfony/routing (v4.0.6): Loading from cache
- Installing symfony/process (v4.0.6): Loading from cache
- Installing symfony/http-foundation (v4.0.6): Loading from cache
- Installing symfony/event-dispatcher (v4.0.6): Loading from cache
- Installing psr/log (1.0.2): Loading from cache
- Installing symfony/debug (v4.0.6): Loading from cache
- Installing symfony/http-kernel (v4.0.6): Loading from cache
- Installing symfony/finder (v4.0.6): Loading from cache
- Installing symfony/console (v4.0.6): Loading from cache
- Installing egulias/email-validator (2.1.3): Loading from cache
- Installing swiftmailer/swiftmailer (v6.0.2): Loading from cache
- Installing paragonie/random_compat (v2.0.11): Loading from cache
- Installing ramsey/uuid (3.7.3): Loading from cache
- Installing psr/simple-cache (1.0.1): Loading from cache
- Installing psr/container (1.0.0): Loading from cache
- Installing symfony/translation (v4.0.6): Loading from cache
- Installing nesbot/carbon (1.25.0): Loading from cache
- Installing monolog/monolog (1.23.0): Loading from cache
- Installing league/flysystem (1.0.43): Loading from cache
- Installing laravel/framework (v5.6.14): Downloading (100%)
- Installing fideloper/proxy (4.0.0): Loading from cache
- Installing jakub-onderka/php-console-color (0.1): Loading from cache
- Installing nikic/php-parser (v3.1.5): Loading from cache
and etc.
Is it okay, or am I doing something wrong?
I use command
laravel new exampleProject
You aren't doing anything wrong, that's the expected behaviour when you install a Laravel project dependencies.
The thing is composer not only installs the dependencies listed in that project composer.json but also the dependencies of the dependencies and so on recursively.
For example, the Laravel application composer file requires the following dependencies:
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0"
}
but composer has to make sure you also have every dependency needed to run these, so it looks in their respective composer.json files, like in the laravel/framework one, which contains this:
"require": {
"php": "^7.1.3",
"ext-mbstring": "*",
"ext-openssl": "*",
"doctrine/inflector": "~1.1",
"dragonmantank/cron-expression": "~2.0",
"erusev/parsedown": "~1.7",
"league/flysystem": "^1.0.8",
"monolog/monolog": "~1.12",
"nesbot/carbon": "^1.24.1",
"psr/container": "~1.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^3.7",
"swiftmailer/swiftmailer": "~6.0",
"symfony/console": "~4.0",
"symfony/debug": "~4.0",
"symfony/finder": "~4.0",
"symfony/http-foundation": "~4.0",
"symfony/http-kernel": "~4.0",
"symfony/process": "~4.0",
"symfony/routing": "~4.0",
"symfony/var-dumper": "~4.0",
"tijsverkoyen/css-to-inline-styles": "^2.2.1",
"vlucas/phpdotenv": "~2.2"
}
it installs them and so on and so forth until it has fulfilled every dependency.
As you can imagine this can add up fast, and once installed every single dependency in your project is listed in your composer.lock file if you want to check them out.
That's why you are getting more dependencies installed than you were expecting.

Unable to update symfony version using composer

I want to update the Symfony version of our app from 2.7.13 to 2.7.38.
I updated composer.json but when I try to update, it throws an error.
Command:
composer update symfony/symfony --with-dependencies
Error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit 4.7.7 conflicts with symfony/symfony[v2.7.38].
This version of Symfony actively refuses to use phpunit/phpunit < 4.8.35 by using conflict in https://github.com/symfony/symfony/blob/v2.7.38/composer.json:
"conflict": {
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
},
You should upgrade "phpunit/phpunit" to a newer version in your own composer.json. Make sure you're not explicitly requiring a conflicted version and run composer update phpunit/phpunit (or just composer update to update all dependencies)
Try requiring the phpunit/bridge:
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},

unable to make bake work with cakePhp 3.2

I'm trying to create new local project with cakephp 3.2, following the cakephp doc, on wamp local server. I used composer to install it.
Everythings seems ok after installation : I configure my db access on app.php and the cakephp default homepage confirms that everything is OK with the configuration (PHP version & extensions OK / write rights OK / connect to db OK)
But when I try to use bake commands (from my project root directory), I've got an error :
$ bin/cake bake
Could not open input file: /cygdrive/c/wamp64/www/cemafor/bin/cake.php
However, the file c/wamp64/www/cemafor/bin/cake.php exists !
I try to use "./bin/cake bake" command (according to cakephp bake doc recommendation), still the same error.
Try also to remove and reinstall the project, no change.
I saw the bake version installed was 1.2.1 (see the result of install command). I've looked into /composer.json file, and saw this :
"require-dev": {
"psy/psysh": "#stable",
"cakephp/debug_kit": "~3.2",
"cakephp/bake": "~1.1"
},
So I try to change version value for cakephp/bake version by this :
"cakephp/bake": "~1.2"
But doesn't change anything...
I try to install version 1.0 according to bake doc but doesn't work.
And unable to find a single person having the same problem... feel alone in the world with a stupid bug ^^
Thanks a lot for your help !
For information, here is the result of the instal command :
$ composer create-project --prefer-dist cakephp/app cemafor
Installing cakephp/app (3.2.1)
- Installing cakephp/app (3.2.1)
Loading from cache
Created project in cemafor
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing aura/installer-default (1.0.0)
Loading from cache
- Installing cakephp/plugin-installer (0.0.12)
Loading from cache
- Installing psr/log (1.0.0)
Loading from cache
- Installing mobiledetect/mobiledetectlib (2.8.19)
Loading from cache
- Installing aura/intl (1.1.1)
Loading from cache
- Installing cakephp/chronos (0.4.7)
Loading from cache
- Installing cakephp/cakephp (3.2.3)
Loading from cache
- Installing symfony/yaml (v3.0.3)
Loading from cache
- Installing symfony/filesystem (v3.0.3)
Loading from cache
- Installing symfony/config (v3.0.3)
Loading from cache
- Installing symfony/polyfill-mbstring (v1.1.0)
Loading from cache
- Installing symfony/console (v3.0.3)
Loading from cache
- Installing robmorgan/phinx (v0.5.1)
Loading from cache
- Installing cakephp/migrations (1.5.6)
Loading from cache
- Installing jakub-onderka/php-console-color (0.1)
Loading from cache
- Installing jakub-onderka/php-console-highlighter (v0.3.2)
Loading from cache
- Installing dnoegel/php-xdg-base-dir (0.1)
Loading from cache
- Installing nikic/php-parser (v2.0.1)
Loading from cache
- Installing symfony/var-dumper (v3.0.3)
Loading from cache
- Installing psy/psysh (v0.7.1)
Loading from cache
- Installing jdorn/sql-formatter (v1.2.17)
Loading from cache
- Installing cakephp/debug_kit (3.2.6)
Loading from cache
- Installing cakephp/bake (1.2.1)
Loading from cache
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/process ()
symfony/var-dumper suggests installing ext-symfony_debug ()
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-posix (If you have PCNTL, you'll want the POSIX extension as well.)
psy/psysh suggests installing ext-readline (Enables support for arrow-key history navigation, and showing and manipulating command history.)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
cakephp/debug_kit suggests installing ext-sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Created `config/app.php` file
Set Folder Permissions ? (Default to Y) [Y,n]? Y
Updated Security.salt value in config/app.php
And here is my composer.json content :
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "http://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=5.5.9",
"cakephp/cakephp": "~3.2",
"mobiledetect/mobiledetectlib": "2.*",
"cakephp/migrations": "~1.0",
"cakephp/plugin-installer": "*"
},
"require-dev": {
"psy/psysh": "#stable",
"cakephp/debug_kit": "~3.2",
"cakephp/bake": "^1.2"
},
"suggest": {
"phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
"cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
},
"autoload": {
"psr-4": {
"App\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump"
},
"minimum-stability": "stable",
"prefer-stable": true
}
Finally succeed !
...fiercely helps compensate incompetence ^^
I follow the steps here : https://stackoverflow.com/a/14904607/2614077.
On the step 4, when I edit /bin/php file (in notepadd++ in my case), I have 2 small operations to do to make it work :
convert document to a UNIX format
encode it on UTF8 (without BOM)
This time everything work fine.
Happy to finally been abble to solve this problem.
Thanks a lot.

Downgrade Doctrine ORm 2.5 to 2.4

i want Downgrade Doctrine Orm 2.5 to 2.4 For solve this Error :
syntax error, unexpected '[', expecting ')'
Note : My php Version : 5.3 (Doctrine 2.5 needed to php 5.4 and later version)
And write this Code in Composer.json file :
{
"require": {
"doctrine/common": "2.4.*",
"doctrine/dbal": "2.4.*",
"doctrine/orm": "2.4.*"
}
}
and run composer task in cmd with this Code :
composer install
But Composer Download Doctrine 2.5
How Download Doctrine 2.4 With Composer
I just did a quick test and it downloads 2.4
just put this composer.json into a folder an run composer install:
composer.json
{
"name": "test/test",
"description": "test",
"license": "no",
"require": {
"doctrine/common": "2.4.*",
"doctrine/dbal": "2.4.*",
"doctrine/orm": "2.4.*"
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
As you can see in composer install output, doctrine/common, doctrine/dbal and doctrine/orm are all version 2.4.x. I run the test also with "preferred-install": "source" and "minimum-stability": "dev" same result.
composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing doctrine/lexer (v1.0.1)
Loading from cache
- Installing doctrine/annotations (v1.2.4)
Loading from cache
- Installing doctrine/collections (v1.3.0)
Loading from cache
- Installing doctrine/cache (v1.4.1)
Loading from cache
- Installing doctrine/inflector (v1.0.1)
Loading from cache
- Installing doctrine/common (v2.4.2)
Loading from cache
- Installing symfony/console (v2.6.7)
Loading from cache
- Installing doctrine/dbal (v2.4.4)
Loading from cache
- Installing doctrine/orm (v2.4.7)
Loading from cache
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/process ()
symfony/console suggests installing psr/log (For using the console logger)
doctrine/orm suggests installing symfony/yaml (If you want to use YAML Metadata Mapping Driver)
Writing lock file
Generating autoload files

Composer failing with php version when --no-dev is passed

I have a composer file with a dev-dependency that requires PHP >= 5.4.0. When I update on production (a 5.3 install (yes - I know!)) and explicitly pass the --no-dev option, composer still checks for the PHP version requirements from the dev packages.
Composer file:
{
"config": {
"vendor-dir": "./vendor/"
},
"require": {
"symfony/config" : "dev-master",
"twig/twig": "1.15.1",
"leafo/lessphp": "v0.4.0",
"simplepie/simplepie": "dev-master",
"contao/idna": "dev-master",
"swiftmailer/swiftmailer": "5.3.*#dev",
"james-heinrich/getid3": "dev-master",
"pda/pheanstalk": "v2.1.0",
"monolog/monolog": "1.9.1",
"pimple/pimple": ">1.0.0",
"doctrine/orm": "2.4.*",
"ircmaxell/password-compat": "1.0.3",
"raven/raven": "dev-curl-async",
"elasticsearch/elasticsearch": "~1.0",
"guzzle/guzzle": "3.9.2"
},
"require-dev": {
"codeception/codeception": "2.1.*#dev"
}
}
Codeception has a requirement for PHP 5.4.0+ and when I run composer update --no-dev I get the following:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for codeception/codeception 2.1.*#dev -> satisfiable by codeception/codeception[2.1.x-dev].
- codeception/codeception 2.1.x-dev requires php >=5.4.0 -> no matching package found.
Should composer be skipping the requirements checks for packages I've explicitly told it not to install? I have tried passing --ignore-platform-reqs but without success.
UPDATE
It appears that running it on PHP 5.3.10 completely ignores the --no-dev option and reports that it is installaling them:
composer update --no-dev
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for codeception/codeception 2.1.*#dev -> satisfiable by codeception/codeception[2.1.x-dev].
- codeception/codeception 2.1.x-dev requires php >=5.4.0 -> no matching package found.
You need to use --no-dev to not install the dev packages.
Solved!!!
It appears my composer file was a bash script that wasn't passing the parameters to the composer.phar file correctly.
This problem was of my own creation.

Categories