Symfony 2.8 How to include GuzzleHttp as Bundle - symfony

Guzzle is outdated and so I installed instead via composer the recommended replacement
"guzzlehttp/guzzle": "^6.3",
I checked in the vendor directory and there is my guzzlehttp lib:
guzzlehttp, although I also still see the old guzzle even after deleting the whole vendor directory and doing composer update again.
However in my Appkernel.php I want to include now guzzlehttp instead of the old eightpoint guzzle as a Bundle and wonder how to do that.
The old syntax was like this:
new EightPoints\Bundle\GuzzleBundle\GuzzleBundle(),
I tried with
new GuzzleHttp\GuzzleBundle(),
But it isn't found. Do I miss another step? If yes which one?
Edit:
original composer.json where I want to replace guzzle with the guzzleHttp since this guzzle package seems to be abandoned:
"require": {
"php": ">=7.0",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"eightpoints/guzzle-bundle": "4.5.*",
"symfony/finder": "^2.8",
"jms/serializer-bundle": "^1.1",
"jms/di-extra-bundle": "~1.3",
"jms/aop-bundle": "~1.1",
"jms/cg": "~1.1",
"psr/cache": "~1.0",
"predis/predis": "1.*",
"snc/redis-bundle": "2.*",
"cache/predis-adapter": "*",
"willdurand/hateoas-bundle": "^1.0",
"hautelook/templated-uri-bundle": "^2.0",
"willdurand/rest-extra-bundle": "^1.0",
"friendsofsymfony/rest-bundle": "^1.7",
"friendsofsymfony/http-cache-bundle": "^1.0",
"avtonom/semaphore-bundle": "dev-master",
"symfony/stopwatch": "*"
},
"require-dev": {
"sensio/generator-bundle": "*",
"phpunit/phpunit": "*",
"phpunit/php-invoker": "*",
"squizlabs/php_codesniffer": "*",
"friendsofphp/php-cs-fixer": "*",
"diablomedia/phpunit-pretty-printer": "*"
},
....

The Guzzle lib does not provide any Symfony integration. Seems like you are using an old version of EightPointsGuzzleBundle.
Instead of requiring guzzlehttp/guzzle which is just a lib, do composer require eightpoints/guzzle-bundle and then in your AppKernel add
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle()
Maybe you should just update your bundle to a newer version.

Related

How to enable the annotation reader service for sensio framework controller listener?

After a composer update to fix some vulnerabilities on package used by my application, I handle an error:
The service "sensio_framework_extra.controller.listener" has a dependency on a non-existent service "annotation_reader"
As suggested in this answer, I tried to add the doctrine/annotations package, but it doesn't solved my issue (package seems to be already installed).
λ composer require doctrine/annotations
Using version ^1.8 for doctrine/annotations
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "4.2.*"
Nothing to install or update
Here is the packages used by my composer.json:
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-json": "*",
"doctrine/doctrine-fixtures-bundle": "^3.1",
"ekyna/payum-monetico-bundle": "^1.5",
"gedmo/doctrine-extensions": "^2.4",
"knplabs/knp-paginator-bundle": "^3.0",
"payum/offline": "^1.5",
"payum/paypal-express-checkout-nvp": "^1.5",
"payum/payum-bundle": "^2.3",
"php-http/guzzle6-adapter": "^2.0",
"sensio/framework-extra-bundle": "^5.1",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/asset": "4.2.*",
"symfony/console": "4.2.*",
"symfony/dotenv": "4.2.*",
"symfony/expression-language": "4.2.*",
"symfony/flex": "^1.1",
"symfony/form": "4.2.*",
"symfony/framework-bundle": "4.2.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "1.*",
"symfony/process": "4.2.*",
"symfony/security-bundle": "4.2.*",
"symfony/serializer-pack": "1.*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/templating": "4.2.*",
"symfony/translation": "4.2.*",
"symfony/twig-bundle": "4.2.*",
"symfony/validator": "4.2.*",
"symfony/web-link": "4.2.*",
"symfony/webpack-encore-bundle": "^1.4",
"symfony/yaml": "4.2.*",
"twig/extensions": "^1.5",
"vich/uploader-bundle": "^1.8"
},
"require-dev": {
"codeception/codeception": "^2.5",
"codeception/c3": "2.*",
"friendsofphp/php-cs-fixer": "^2.14",
"php-coveralls/php-coveralls": "^2.1",
"phpmd/phpmd": "2.*",
"squizlabs/php_codesniffer": "*",
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.11",
"symfony/profiler-pack": "*",
"symfony/test-pack": "^1.0",
"symfony/web-server-bundle": "4.2.*"
}
Edit :
I'm using all the framework, I've manually dropped cache to be sure there is no problem. I rebooted my dev computer too. Finally, I went around the problem by deploying my github project in another directory and application works fine. I don't close this question because I want to find the problem if it occurs in production.
since doctrine (or doctrine/annotations) itself does not register services (why would it), I looked up the doctrine bundles and the doctrine/doctrine-bundle provides the annotation_reader service: https://github.com/doctrine/DoctrineBundle/blob/af8ac792c9b970ff2bc25b49ab9b31afd9e03dbf/Resources/config/orm.xml#L82
I ran into a very similar error (The service "doctrine.orm.default_annotation_metadata_driver" has a dependency on a non-existent service "annotation_reader".) while trying to create a new setup. I have some instructions documented and had tried to composer install ormfixtures (--dev) before doctrine. Once I did that in the right order, everything was working as expected.
My specific example is from Twilio's instructions, which have these commands in this order:
composer req --dev maker ormfixtures fakerphp/faker
composer req doctrine twig
It worked when I reversed them to be in this order:
composer req doctrine twig
composer req --dev maker ormfixtures fakerphp/faker
I Had the same issue after a composer update from Symfony 4.4.
It was because I have replace de "Doctrine\Common" with "Doctrine" from all the using instead of "Doctrine\Common\Persistence" with "Doctrine\Persistence".
In other term: no matters why you have this error, it come from a broken namespace in your code.
This is the official link of the SensioFrameworkExtraBundle: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html

Composer error when I want to install fosuserbundle

When I use this command in cmd
php composer.phar update friendsofsymfony/user-bundle
I get this message
Please provide a version constraint for the
friendsofsymfony/user-bundle requirement: 2.0.*#dev composer.json has
been updated 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
- The requested package friendsofsymfony/user-bundle could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting see
https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion
for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for
further common problems.
Installation failed, reverting composer.json to its original content.
I've already added "minimum-stability": "dev", in my composer.json
It's the first time that I head this problem I installed fosuserbundle manytimes and it worked before.
I just Advice you just use this to configure all the sonata admin + fos user bundle without any dependencies or version conflicts
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.5.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"sonata-project/admin-bundle": "~2.3#dev",
"sonata-project/doctrine-orm-admin-bundle": "~2.3#dev",
"sonata-project/core-bundle": "~2.2#dev",
"sonata-project/user-bundle": "2.2.x-dev",
"friendsofsymfony/user-bundle": "~1.3#dev",
"sonata-project/easy-extends-bundle": "~2.1#dev",
"sonata-project/intl-bundle": "2.2.x-dev",
"knplabs/knp-paginator-bundle": "dev-master",
"knplabs/knp-time-bundle": "dev-master",
"knplabs/knp-menu-bundle": "1.1.*",
"jms/serializer-bundle": "0.13.*#dev"
},
So I fixed, it should be:
"friendsofsymfony/user-bundle": "~2.0#dev"
not
"friendsofsymfony/user-bundle ": "~2.0#dev"

Call to method setCurrentUri fails in Symfony/SonataUserBundle setup

I am trying to set up Symfony with the SonataUserBundle. User registration and login works fine. When I try to call up the /profile view, however I get the following error:
Attempted to call method "setCurrentUri" on class "Knp\Menu\MenuItem" in F:\<my project path>\vendor\sonata-project\user-bundle\Block\ProfileMenuBlockService.php line 91. Did you mean to call: "setCurrent"?
The last notice in the "event list" before the error is
INFO - [cms::renderBlock] block.id=53, block.type=sonata.user.block.menu
Has anyone encountered this error before and can provide information on how to resolve it?
TIA
Matt
What versions of KnpMenu and SonataBlockBundle are you using? Please check your composer.json to be sure.
The setCurrentUri method has been deprecated as of KnpMenu v. 2.0, and the composer.json of SonataBlockBundle does not require KnpMenu anywhere but in dev install. So, this leads to a possibility that you could have required a fresher version of knplabs/knp-menu-bundle that is not yet supported by Sonata bundle.
Try requiring knplabs/knp-menu-bundle in 1.1.x:
{
...
"require": {
"knplabs/knp-menu-bundle": "~1.1"
},
...
}
I encountered the same problem, but downgrade to Knpmenu version 1 is not possible for our project. Because of some code update the June 16th, it is now possible to use Sonata User Bundle and Knp Menu Version 2.
Please, have a look on my composer.json :
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/migrations": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "~1.3",
"friendsofsymfony/message-bundle": "^1.2",
"sonata-project/admin-bundle": "^2.3",
"sonata-project/doctrine-orm-admin-bundle": "^2.3",
"sonata-project/easy-extends-bundle": "^2.1",
"sonata-project/user-bundle": "dev-master",
"sonata-project/datagrid-bundle": "dev-master",
"sonata-project/block-bundle": "~2.2,>=2.2.7,<2.3",
"sonata-project/exporter": "^1.4",
"sonata-project/intl-bundle": "^2.2",
"knplabs/knp-menu-bundle": "~2.0",
"knplabs/knp-menu": "~2.0"
},
As you can see, sonata-project/user-bundle is under dev-master version and I had to add sonata-project/datagrid-bundle in dev-master
Hope to help developpers who want want to preserve KnpMenu V2 !
I had same issue, This is my solution that you can preserve KnpMenu V2.
-You change setCurrentUri to setCurrent (because KNP changed code) in C:\path\vendor\sonata-project\user-bundle\Block\ProfileMenuBlockService.php
-You can have this problem, Method "currentAncestor" for object "Knp\Menu\MenuItem" does not exist in Sonata
And this works for me.

Sylius old composer update

I have used sylius as e-commerce platform and working on it by creating my own website.
After 4 months of job I want to extend my system with one more bundle using composer.json.
But there is problem when I want to update composer via json, sylius bundles makes problem like there is changes in sylius bundles, I can't update anymore old sylius composer, seems like my work in last 4 months by using sylius is gone?
Can anybody help is there any solution to continue my work with old sylius's composer.json?
There is problem with inventory bundle that was 0.1.* now is that version removed and there is 1.0 version which is not satisfailable for the rest of my bundles as omnipay , flow bundle etc... and when I resolve one of them that goes in next couple like there is no solution?
Error:
Problem 1
- The requested package sylius/installer-bundle 0.1.* could not be found.
Problem 2
- The requested package sylius/omnipay-bundle 0.9.*#dev could not be found.
Problem 3
- Installation request for sylius/flow-bundle 0.1.* -> satisfiable by sylius/flow-bundle[v0.1.0].
- sylius/flow-bundle v0.1.0 requires sylius/installer-bundle 0.1.* -> no matching package found.
"php": ">=5.3.3",
"symfony/symfony": ">=2.2,<2.3-dev",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"doctrine/doctrine-fixtures-bundle": "*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"incenteev/composer-parameter-handler": "~2.0",
"mathiasverraes/money": "dev-master#dev",
"jms/translation-bundle": "1.1.*",
"sylius/installer-bundle": "0.1.*",
"sylius/assortment-bundle": "0.1.*",
"sylius/cart-bundle": "0.3.*",
"sylius/money-bundle": "0.1.*",
"sylius/taxation-bundle": "0.1.*",
"sylius/shipping-bundle": "0.1.*",
"sylius/addressing-bundle": "0.1.*",
"sylius/sales-bundle": "0.1.*",
"sylius/promotions-bundle": "0.1.*",
"sylius/inventory-bundle": "0.1.*",
"sylius/taxonomies-bundle": "0.1.*",
"sylius/settings-bundle": "0.1.*",
"sylius/payments-bundle": "0.1.*",
"sylius/flow-bundle": "0.1.*",
"sylius/resource-bundle": "0.1.*",
"sylius/omnipay-bundle": "0.9.*#dev",
"jms/serializer-bundle": "0.11.*",
"friendsofsymfony/user-bundle": "1.3.1",
"fsc/hateoas-bundle": "0.3.x-dev",
"knplabs/knp-gaufrette-bundle": "0.2.*",
"fzaninotto/faker": "1.1.*",
"knplabs/knp-menu-bundle": "2.0.*",
"liip/imagine-bundle": "0.9.*",
"athari/yalinqo": "*",
"friendsofsymfony/facebook-bundle": "1.1.*",
"doctrine/migrations": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master",
"friendsofsymfony/elastica-bundle": "3.0.*#dev",
"excelwebzone/recaptcha-bundle": "dev-master",
"knplabs/knp-paginator-bundle": "dev-master",
"knplabs/knp-snappy-bundle": "dev-master",
"paypal/adaptivepayments-sdk-php": "dev-master",
"mandrill/mandrill": "1.0.*"
You should require "1.0." or "1.0.#dev" depending on your minimum-stability setting. You can also lock on specific tags.

Upgrading Symfony2 and SonataAdminBundle (Mar 01, 2013) after last update

After last update SonataAdminBundle (Mar 01, 2013) I can not update components using composer
composer.json
...
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.1.*",
"twig/extensions": "1.0.*#dev",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
"symfony/monolog-bundle": "2.1.*",
"sensio/distribution-bundle": "2.1.*",
"sensio/framework-extra-bundle": "2.1.*",
"sensio/generator-bundle": "2.1.*",
"jms/security-extra-bundle": "1.2.*",
"jms/di-extra-bundle": "1.1.*",
"kriswallsmith/assetic": "1.1.*#dev",
...
"sonata-project/admin-bundle": "dev-master",
"sonata-project/intl-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/cache-bundle": "dev-master"
},
...
php composer.phar update symfony/symfony
Problem 1
- Installation request for sonata-project/admin-bundle dev-master -> satisfiable by sonata-project/admin-bundle dev-master.
- Can only install one of: sonata-project/admin-bundle dev-master, sonata-project/admin-bundle 2.1.x-dev.
- Installation request for sonata-project/admin-bundle == 2.1.9999999.9999999-dev -> satisfiable by sonata-project/admin-bundle 2.1.x-dev.
You have set the version of the sonata-project packages to dev-master. The master branch is in sync with the symfony's stable release. Since Symfony2.2 is released on 1 march, you need to update these versions to not require Symfony2.2, or update your project to symfony2.2 (shouldn't be that difficult).
Solution 1: Updating sonata-project versions
Change this:
"sonata-project/admin-bundle": "dev-master",
"sonata-project/intl-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/cache-bundle": "dev-master"
to
"sonata-project/admin-bundle": "2.1.x",
"sonata-project/intl-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "2.1.x",
"sonata-project/cache-bundle": "dev-master"
Solution 2: Updating Symfony2.1 to 2.2
Read the news article on how to update your project from Symfony2.1 to 2.2. Basically, this means updating the composer.json according to the changes on the main repo, running php composer.phar update and reading the UPGRADE-2.2.md file on what has changed.
Try:
"sonata-project/admin-bundle": "2.1.*",
"sonata-project/doctrine-orm-admin-bundle": "2.1.*#dev",
"sonata-project/intl-bundle": "2.1.*",
"sonata-project/cache-bundle": "2.1.*"
It's work for me.

Resources