In Composer force install when bundle requires older version of symfony2 - symfony

The title I think is pretty clear: how do I install a bundle that requires a slightly older version of symfony?
For example: I have the 2.4.* and the bundle requires 2.3.*.
I am sure that the bundle will also work for this version, but composer doesn't allow me to install it.
How can I resolve?

Related

How to install patched modules in fresh Drupal 10 Installation?

I have a fresh Drupal 10 Installation und would like to install some modules with more ore less simple patches. I tried it in different ways and get allways the same errors with composer require.
This are my steps:
manual changed files for exampe in superfish for this patch:
https://www.drupal.org/files/issues/2022-08-01/superfish-%233.patch and manually put the module in module/contrib folder. Than I tried composer require drupal/superfish:~1.4 with different versions and with and without parameter -W.
I wrote patch in composer.json and tried composer install. There comes the message nothing to install or update. I used also composer update --lock
I downloaded last dev-Version and patch and tried with git apply.
The result with composer require is more ore less the same error like this:
Problem 1 - drupal/block_content_permissions[1.0.0, ..., 1.8.0]
require drupal/core ^8 -> found drupal/core[8.0.0, ..., 8.9.20] but
these were not loaded, likely because it conflicts with another
require. - drupal/block_content_permissions[1.9.0, ..., 1.10.0]
require drupal/core ^8 || ^9 -> found drupal/core[8.0.0, ..., 8.9.20,
9.0.0, ..., 9.5.0] but these were not loaded, likely because it conflicts with another require. - Root composer.json requires
drupal/block_content_permissions * -> satisfiable by
drupal/block_content_permissions[1.0.0, ..., 1.10.0].
You can also try re-running composer require with an explicit version
constraint, e.g. "composer require drupal/block_content_permissions:*"
to figure out if any version is installable, or "composer require
drupal/block_content_permissions:^2.1" if you know which you need.
If I enable the patched modules manualy in backend, they work normaly. But they are not under composer controll.
How to do in the right way?
Drupal.org has a documented process for allowing a lenient composer install.
For Drupal 10:
Try the Lenient Composer Plugin
The lenient composer plugin lets you specify an allowlist of packages
where you are willing to break the version constraint, using a command
like:
composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/token"]'
Together with the Composer Patches Plugin, this allows you to install
any Drupal extension, even if the version constraint hasn't been
officially updated yet. Of course the code may still need to be
patched for deprecations.

Can not install annotations

I tried installing annotations for symfony. But I can not install it.
composer require annotations
I tried writing "composer require annotations"
-> https://save.jb-dev.eu/img/NWgZ7LPOv0.png
Does anyone have any idea what the problem might be?
if you use Symfony flex
composer require annotations
if you don't use Symfony Flex, add it to your composer.json file
or you can use this command
composer require sensio/framework-extra-bundle
First, try the following command,
composer require sensio/framework-extra-bundle
Then run this command,
composer require annotation
Then it will work perfect.

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

How do you register bundles in Symfony2.1 designed for older versions of Symfony?

I am attempting to use they EntityAudit extension for Doctrine2 in my Symfony2.1 app.
I'm very new to this, and I've just started realizing how many "correct" methods there have been for installing new bundles for Symfony over the years. Some sort of "Deps" file used to exist but does no longer? When installing Symfony, "using Composer" was an option -- but purely an option, it seemed. Now I'm starting to think that's not true.
In EntityAudit's instructions it refers to "Autoload", and based on other things, I'm apparently supposed to modify the registerNamespaces array in my Autoload.php. Except I don't have that. So I found this link where the guy indicates Symfony2.1 doesn't do that anymore in favor of using Composer.
I don't really know how to use Composer in this case though. I don't really know how to use it at all, actually, but I seem to have bumbled through doing 1 or 2 basic things in it -- "updating" itself and "installing" .. vendors? Anyway, I can find no instructions general enough to be adapted for this need. Thanks in advance for any help!
The deps file is used in 2.0 to manage dependencies. The 2.1 version uses the much better Composer dependency management tool.
Install with composer
First you'll need some basix about composer. For instance, read this article: http://net.tutsplus.com/tutorials/php/easy-package-management-with-composer/
Before you can use composer to install a bundle you should look for a Packagist package of that bundle. For the SimpleThings\EntityAuditBundle you should look for a simplethings/entity-audit-bundle package and it does exists: https://packagist.org/packages/simplethings/entity-audit-bundle
SIDENOTE
Packagist is the main archive for Composer.
If you are searching for a bundle, the best thing you can do is check out
KnpBundles, it is the unofficial achive of Symfony Bundles.
If a bundle contains a README file, it is displayed there and if it has a Packagist
package it shows a link to the package. It's a really usefull site to begin searching
for bundles.
Now you have the package name, you should determine the version you want to use. As this is a not-finished bundle we can use the latest version by using the dev-master version. But it could be possible that a dev-master version is for Symfony2.2 and we should use another version if we use Symfony2.1, this should be in the README file (in the Package, which you can view on Github or KnpBundles). If it isn't in the README, you can use the version you want. An example of the note about version can be found in the StofDoctrineExtensionsBundle.
Now we can add the bundle to our composer.json file and update the dependencies. You can do this manually:
Add it to the composer.json file:
{
...,
"require": {
...,
"simplethings/entity-audit-bundle": "dev-master"
}
}
Update the dependency
$ php composer.phar update simplethings/entity-audit-bundle
or update all dependencies
$ php composer.phar update
Or you can do this is one command:
Run this command (which includes the package in the composer.json and updates the package)
$ php composer.phar require simplethings/entity-audit-bundle:dev-master
Now the bundle is installed into our Symfony project (in vendor/simpletings/) and the autoloader recognises this bundle. The only thing we need to do now is registering the bundle in the AppKernel:
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
...,
new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
);
// ...
}
}

Resources