I have a package in a private github repository.
When I run composer require my_vendor/my_package the package gets added to composer.json and shows up in the vendor directory.
When I run composer remove my_vendor/my_package it gives me a warning:
Package "my_vendor/my_package" listed for update is not installed.
Ignoring.
So when I run composer prohibits my_vendor/my_package it says
Could not find package "my_vendor/my_package" in your project
If I run composer show (after requiring the package) it is not displayed in the list.
This package has a dependency (lexik/authenticationbundle) which is correctly installed, removed and show in list of installed packages (but not listed in the tree view since it is a dependency of a non existent package)...
I have no clue on what could explain this behavior.
Any suggestion?
edit (adding composer.json content)
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/api-pack": "^1.1",
"composer/composer": "^1.6",
"symfony/console": "^4.1",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.1",
"symfony/lts": "^4#dev",
"symfony/orm-pack": "^1.0",
"symfony/web-server-bundle": "^4.1",
"symfony/yaml": "^4.1"
},
"require-dev": {
"symfony/dotenv": "^4.1"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/my_repo/my_package.git"
}
],
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"cache:clear": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-package-install": [
"App\\Utility\\Bootstrap\\Setup::execute",
"#auto-scripts"
],
"pre-package-uninstall": [
"App\\Utility\\Bootstrap\\Demolish::execute",
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "01C1K60FQVPP7FCAC3YB6639RZ",
"allow-contrib": true
}
}
}
Furthermore, creating a new project and requiring the package correctly adds it to the list of installed packages, thus removing it works fine. Then I tried to delete lock file and running a composer update and eventually I tried to require/remove it but with no luck.
It appears that what was preventing composer to correctly configure required package was a die() in the post-package-install script.
Removing the statement solved the issue.
Related
I'm trying to start a new symfony --version=5.2 project, and before everything else I'm installing the symfony maker bundle, but I get this error which I can't find no solution for it.
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^1.43 for symfony/maker-bundle
./composer.json has been updated
Running composer update symfony/maker-bundle
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires symfony/maker-bundle ^1.43 -> satisfiable by symfony/maker-bundle[v1.43.0].
- symfony/maker-bundle v1.43.0 requires symfony/config ^5.4.7|^6.0 -> found symfony/config[v5.4.7, v5.4.8, v5.4.9, v6.0.0, ..., v6.1.0] but the package is fixed to v5.2.12 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require symfony/maker-bundle:*" to figure out if any version is installable, or "composer require symfony/maker-bundle:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I tried changing the maker-bundle version myself but still got the same error.
I tried to search for similar problems but no luck finding this error.
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.12",
"symfony/console": "5.2.*",
"symfony/dotenv": "5.2.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.2.*",
"symfony/http-client": "5.2.*",
"symfony/proxy-manager-bridge": "5.2.*",
"symfony/yaml": "5.2.*"
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"docker": false,
"require": "5.2.*"
}
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "5.2.*",
"symfony/css-selector": "5.2.*",
"symfony/phpunit-bridge": "^6.1"
}
}
This has just randomly started happening and i've never seen this so i'm not sure how to fix it. I came to reinstall all the plugins for a bedrock install from wpackagist and instead of going into web/app/plugins they are all installing in the vendor folder. They weren't doing this last time i installed them, here is composer.json, nothing has changed so i don't know what is going on:
{
"name": "roots/bedrock",
"type": "project",
"license": "MIT",
"description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
"homepage": "https://roots.io/bedrock/",
"authors": [
{
"name": "Scott Walkinshaw",
"email": "scott.walkinshaw#gmail.com",
"homepage": "https://github.com/swalkinshaw"
},
{
"name": "Ben Word",
"email": "ben#benword.com",
"homepage": "https://github.com/retlehs"
}
],
"keywords": [
"bedrock", "composer", "roots", "wordpress", "wp", "wp-config"
],
"support": {
"issues": "https://github.com/roots/bedrock/issues",
"forum": "https://discourse.roots.io/category/bedrock"
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": ["wpackagist-plugin/*", "wpackagist-theme/*"]
},
{
"type": "vcs",
"url": "git#github.com:clickds/save-share-cart.git"
},
{
"type": "vcs",
"url" : "git#github.com:clickds/woocommerce-additional-variation-images.git"
}
],
"require": {
"php": ">=7.1",
"composer/installers": "^1.11",
"vlucas/phpdotenv": "^5.3",
"oscarotero/env": "^2.1",
"roots/bedrock-autoloader": "^1.0",
"roots/bedrock-disallow-indexing": "^2.0",
"roots/wordpress": "5.8",
"roots/wp-config": "1.0.0",
"roots/wp-password-bcrypt": "1.0.0",
"wpackagist-plugin/woocommerce": "^5.7",
"wpackagist-plugin/disable-gutenberg": "^2.5",
"wpackagist-plugin/custom-field-builder": "^1.2",
"clickds/save-share-cart" : "^1.0.4",
"wpackagist-plugin/woocommerce-gateway-stripe": "^5.8",
"wpackagist-plugin/all-in-one-wp-security-and-firewall": "^4.4",
"wpackagist-plugin/w3-total-cache": "^2.1",
"wpackagist-plugin/woocommerce-gateway-paypal-express-checkout": "^2.1",
"wpackagist-plugin/simple-taxonomy-ordering": "^2.3",
"wpackagist-plugin/wp-mail-smtp": "^3.2",
"glenelkins84/woocommerce-additional-variation-images" : "^1.9.2",
"wpackagist-plugin/import-xml-feed": "^2.1",
"wpackagist-plugin/woo-variation-swatches": "^1.1",
"wpackagist-plugin/woo-custom-related-products": "^1.3",
"wpackagist-plugin/purchase-orders-for-woocommerce": "^1.8"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.6.0",
"roave/security-advisories": "dev-master"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"allow-plugins": {
"composer/installers": false,
"roots/wordpress-core-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"installer-paths": {
"web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"web/app/plugins/{$name}/": ["type:wordpress-plugin"],
"web/app/themes/{$name}/": ["type:wordpress-theme"]
},
"wordpress-install-dir": "web/wp"
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"test": [
"phpcs"
]
}
}
It seems "WordPress boilerplate" works separately from WordPress core.
Generally, using composer, the installed packages are stored in the vendor folder and can be called by requiring autoload.php file in your project.
I have downgraded a Symfony 5.2 app template to use Symfony 4.4 in order to allow the use of some libraries that require an older version of Symfony. The problem is that when I do composer install, I get this error near the end of the installation:
sh: symfony-cmd: command not found
It seems that the installations are mostly successful, as my vendor folder is created and populated. But I'm worried about the error.
What does this error mean? How do I fix it?
====
Edit: Here's my composer.json file:
{
"type": "project",
"license": "proprietary",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.4.0",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-json": "*",
"composer/package-versions-deprecated": "1.11.99.1",
"cweagans/composer-patches": "^1.7",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.9",
"phpdocumentor/reflection-docblock": "*",
"sensio/framework-extra-bundle": "*",
"symfony/framework-bundle": "4.4.*",
"symfony/http-client": "*",
"symfony/intl": "*",
"symfony/mailer": "*",
"symfony/mime": "*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "*",
"symfony/process": "*",
"symfony/property-access": "*",
"symfony/property-info": "*",
"symfony/proxy-manager-bridge": "*",
"symfony/security-bundle": "*",
"symfony/serializer": "*",
"symfony/string": "*",
"symfony/translation": "*",
"symfony/twig-bundle": "*",
"symfony/validator": "*",
"symfony/web-link": "*",
"symfony/yaml": "*",
"twig/extra-bundle": "*",
"twig/twig": "*"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4",
"roave/security-advisories": "dev-master",
"symfony/browser-kit": "*",
"symfony/css-selector": "*",
"symfony/debug-bundle": "*",
"symfony/maker-bundle": "*",
"symfony/phpunit-bridge": "*",
"symfony/stopwatch": "*",
"symfony/var-dumper": "*",
"symfony/web-profiler-bundle": "*",
"vimeo/psalm": "^4.9"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.2.*"
},
"patches": {
"symfony/maker-bundle": {
"Provide flag to force annotation in make entity command": "https://raw.githubusercontent.com/vklux/maker-bundle-force-annotation/master/maker-force-annotation-flag.patch"
}
}
}
}
For those who have the symfony/flex package installed and are still getting the error, make sure the symfony/flex package is allowed to execute code when running composer.
This is because since Composer 2.2.0 the allow-plugins option adds a layer of security that allows you to restrict which Composer plugins can execute code at startup time.
So make sure you have the appropriate line in the allow-plugins config in your composer.json file
"config": {
// other config...
"allow-plugins": {
"symfony/flex": true
}
},
symfony-cmd is a part of Symfony Flex. Your composer.json does not contain any requirement for Flex, so running composer require symfony/flex might resolve that problem.
While adding symfony/flex to the project is one solution, keep in mind that Flex is optional. If you want to get rid of the error without installing Flex, simply remove the symfony-cmd command references from your composer.json.
Before:
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
After:
"scripts": {
"auto-scripts": {},
"post-install-cmd": [],
"post-update-cmd": []
},
I ran into a special case were an old deploy script added --no-plugins to my composer command. Removing that solved my issue with using deployer v6.
set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader');
Apparently you need plugins for flex to work, and I'm assuming since the scripts block has some commands you need that too. So having no script/plugins will break your installation.
I'm trying to deploy a Symfony 5.2 on Heroku, I've already configured the Procfile and the required Config Vars such APP_ENV (prod), APP_SECRET and others related to the project.
Procfile:
web: vendor/bin/heroku-php-apache2 public/
composer.json:
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"knplabs/knp-paginator-bundle": "^5.2",
"lexik/jwt-authentication-bundle": "^2.8",
"nelmio/cors-bundle": "^2.0",
"sensio/framework-extra-bundle": "^5.5",
"symfony/asset": "5.1.*",
"symfony/console": "5.1.*",
"symfony/dotenv": "5.1.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.1.*",
"symfony/mailer": "5.1.*",
"symfony/orm-pack": "^1.0",
"symfony/security-bundle": "5.1.*",
"symfony/serializer": "5.1.*",
"symfony/yaml": "5.1.*",
"twig/twig": "^3.0"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3",
"symfony/maker-bundle": "^1.19",
"symfony/profiler-pack": "^1.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
],
"compile": [
"php bin/console doctrine:migrations:migrate"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.1.*"
}
}
}
No matter what I do I always end up with an error related to something missing such as:
PHP Fatal error: Uncaught Error: Class 'Symfony\Bundle\TwigBundle\TwigBundle' not found in /tmp/build_271a300c_/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:74
My guess is the problem is related with everything ending up in this /tmp/build_271a300c_ folder and when the project is deployed it lost the refereed folder. But I have no idea what to do with this information I appreciate any help.
Solved the problem with, what I think, is nothing more than a workaround.
The deploy process was complaining always about the require-dev dependencies, so I did:
Moved all require-dev to require;
Run composer update to refresh the composer.lock file;
Pushed and tried the deploy again with success.
This solution was take for many people in other issues I read, I'm just describing step-by-step what was done to fix it. Still, I don't think it's the correct fix for this, after all the dev-dependencies shouldn't being installed on prod environment.
On my initial environment, I have a PHP 7.2.5.
But on the production environment, the version is 7.2.1.
I want to downgrade the version of PHP, but dependencies require 7.2.5 (the localhost:8000 is working fine).
{
"name": "symfony/website-skeleton",
"type": "project",
"license": "MIT",
"description": "A skeleton to start a new Symfony website",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.2",
"ext-ctype": "*",
"ext-iconv": "*",
"knplabs/knp-menu-bundle": "^3.1",
"sensio/framework-extra-bundle": "^5.1",
"symfony/asset": "*",
"symfony/console": "*",
"symfony/dotenv": "*",
"symfony/expression-language": "*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.2.*",
"symfony/framework-bundle": "*",
"symfony/http-client": "*",
"symfony/intl": "*",
"symfony/mailer": "*",
"symfony/mime": "*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "*",
"symfony/orm-pack": "*",
"symfony/process": "*",
"symfony/security-bundle": "5.2.*",
"symfony/serializer-pack": "*",
"symfony/string": "*",
"symfony/translation": "*",
"symfony/twig-pack": "*",
"symfony/validator": "*",
"symfony/web-link": "*",
"symfony/yaml": "*"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.2.*"
}
}
}
How can I fix this error ? For now, if I don't use any composer command, it's fine, but I guess if I use any composer require I'll have an error due to PHP version ?
How can I downgrade all dependencies at the same time than php version ?
Symfony 5.2 requires PHP 7.2.5, so there is no way that you can use Symfony 5.2 with any lower PHP version. The latest Symfony version compatible with PHP 7.2.1 is v4.4.
To perform the downgrade of Symfony, this is the part you need to check:
"extra": {
"symfony": {
"allow-contrib": false,
"require": "5.2.*"
}
}
It specifically asks symfony/flex to use Symfony 5.2. If you want to downgrade Symfony, edit the version here and run composer update.
Keep in mind that this works best when all Symfony components are required without any specific version constraint. symfony/security-bundle should be used with a * requirement, as all other components