Why can't I bind Elasticsearch and Laravel Scout? - php

I decided to test Elasticsearch in conjunction with Laravel Scout. I took this article as a basis
Attempt #1
composer require elasticsearch/elasticsearch - installing ES for Laravel
composer require laravel/scout - installing latest version for Scout (9.1)
composer require tamayo/laravel-scout-elastic - installing package for ES+Scout
I get this error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- tamayo/laravel-scout-elastic[8.0.0, ..., 8.0.2] require laravel/scout ^8.0 -> found laravel/scout[v8.0.0, ..., 8.x-dev] but it conflicts with your root composer.json require (^9.1).
- Root composer.json requires tamayo/laravel-scout-elastic ^8.0 -> satisfiable by tamayo/laravel-scout-elastic[8.0.0, 8.0.1, 8.0.2].
I understand for myself that this bundle package has not been updated on github for six months and it is necessary to get to it the necessary version of laravel/scout, so I change the order of actions and do so:
Attempt #2
composer require elasticsearch/elasticsearch - installing ES for Laravel
composer require tamayo/laravel-scout-elastic - installing this package hoping that he will get the necessary version of laravel/scout for himself as a dependency, in confirmation of this - I see in the console that he pulled up laravel/scout:8.6.1
Now no mistakes, I'm moving on:
I go to config/app.php and add:
Laravel\Scout\ScoutServiceProvider::class,
ScoutEngines\Elasticsearch\ElasticsearchProvider::class,
Run php artisan vendor:publish
And now I get new error:
Class 'ScoutElastic\ScoutElasticServiceProvider' not found
What am I doing wrong?

Solution: don't add ScoutEngines\Elasticsearch\Elastic search Provider:: class, to config/app.php
Everything works fine without adding this provider

Related

I can't install spatie/laravel-sitemap on Laravel 5.6

I'm getting this error when installing:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- spatie/laravel-sitemap[5.9.0, ..., 5.9.2] require illuminate/support ^8.0 -> found illuminate/support[v8.0.0, ...,
8.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires spatie/laravel-sitemap ^5.9 -> satisfiable by spatie/laravel-sitemap[5.9.0, 5.9.1, 5.9.2].
You can also try re-running composer require with an explicit version
constraint, e.g. "composer require spatie/laravel-sitemap:*" to figure
out if any version is installable, or "composer require
spatie/laravel-sitemap:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to
their original content.
you can just
composer require spatie/laravel-sitemap:*
# ^
Composer will figure out if any version (*) is installable (thanks to dependency resolution, compare Dependency Hell etc.).
You can also leave the star (*) out, as it poses some problems in the shell/command interpreter. Example:
composer require spatie/laravel-sitemap
See as well: How to install a specific version of package using Composer?

Symfony - (1/1) InvalidConfigurationException - Unrecognized option "mailer" under "framework"

I'm quite new at Symfony and struggle with this issue for my internship, when trying to run the project locally :
(1/1) InvalidConfigurationException
In ArrayNode.php line 331:
Unrecognized option "mailer" under "framework". Available options are "annotations", "assets", "cache", [...], "workflows".
I'm running PHP 7.4 and Symfony 4, adapting a symfony project from another dev.
In my .env file, I got swiftmailer bundle, I believe mailer was a different kind of mailer bundle used..?
I tried the following request :
composer require symfony/mailer
And got this :
The "symfony/flex" plugin was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.
Using version ^5.2 for symfony/mailer
./composer.json has been updated
The "symfony/flex" plugin was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.
Running composer update symfony/mailer
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- symfony/mailer[v5.2.0, ..., v5.2.2] require symfony/event-dispatcher ^4.4|^5.0 -> found symfony/event-dispatcher[v4.4.0, ..., v4.4.19, v5.0.0, ..., v5.2.2] but the package is fixed to v4.2.8 (lock file version) by a partial up
date and that version does not match. Make sure you list it as an argument for the update command.
- Root composer.json requires symfony/mailer ^5.2 -> satisfiable by symfony/mailer[v5.2.0, v5.2.1, v5.2.2].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
Thanks for your help !
If you're kickstarting another dev's project, you probably don't need any composer require. All you have to do is run composer install in project directory to get all the same packages, as previous developer.

Problem with TravisCI version matrix after updating to composer 2.0

After updating to Composer 2.0 I got into problems on doing my Travis.
I have a TYPO3 Extension, that I want to test with multiple TYPO3 Versions. Till yesterday I could do this with composer require nimut/typo3-complete:$TYPO3_VERSION (coming from the version Matrix).
After the update I got following error/information.
Cannot update only a partial set of packages without a lock file present.
Installation failed, reverting ./composer.json to its original content.
As I have no composer.lock in my repository, I tested my pipeline with a composer install first, and then did the update. This is all fine until I go to the next version as the dependencies are different, and the composer.lock from the composer install cannot update the additional dependencies.
I have tried it with composer require --dev nimut/typo3-complete:^10.4 --with-all-dependencies the response from composer:
Problem 1
- typo3/testing-framework is locked to version 4.15.2 and an update of this package was not requested.
- typo3/testing-framework 4.15.2 requires typo3/cms-backend ^9.3 -> found typo3/cms-backend[v9.3.0, ..., 9.5.x-dev] but it conflicts with another require.
Problem 2
- symfony/http-client v5.1.7 requires symfony/http-client-contracts ^2.2 -> found symfony/http-client-contracts[dev-main, dev-master, v2.2.0, v2.3.1, 2.3.x-dev (alias of dev-master)] but it conflicts with another require.
- nunomaduro/phpinsights v1.14.0 requires sensiolabs/security-checker ^6.0 -> satisfiable by sensiolabs/security-checker[v6.0.3].
- sensiolabs/security-checker v6.0.3 requires symfony/http-client ^4.3|^5.0 -> satisfiable by symfony/http-client[v5.1.7].
- nunomaduro/phpinsights is locked to version v1.14.0 and an update of this package was not requested.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
The -W option is the one I'm trying out already. I have tried both -w and -W, no luck so far.
I'm not sure how to get around this problem yet, your input your be very helpful.
Link to .travis.yml
https://github.com/AOEpeople/crawler/blob/master/.travis.yml#L50
Link to Travis Build where testing it out.
https://travis-ci.org/github/AOEpeople/crawler/jobs/738603105#L1138
The issue with composer require was reported and fixed in PR 9336 on Composer's GitHub repository. It will be in Composer 2.0.2 just about to be released now. So you can upgrade to 2.0.2 and it should resolve your problem.
To explain why your workaround failed:
composer require nimut/typo3-complete:$TYPO3_VERSION edits the composer.json file to add "nimut/typo3-complete": "^$TYPO3_VERSION". Then it runs composer update nimut/typo3-complete, or (on Composer 1.x or 2.0.2+) a plain composer update if no lock file exists yet.
If you run a composer install without a lock file first, this executes a composer update because there is no lock file. The subsequent composer require then still edits the json file and now runs composer update nimut/typo3-complete because there is a lock file. Even with all the dependency options enabled, this may have a different outcome or even a conflict from running a plain composer update as you are restricting the update to only the new package and its dependencies.

Composer fails to download Google Text-To-Speech library

I am trying to import Google's Text-To-Speech library
composer require google/cloud-text-to-speech
But I get this error
Using version ^0.4.4 for google/cloud-text-to-speech
./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
- Installation request for google/cloud-text-to-speech ^0.4.4 -> satisfiable by google/cloud-text-to-speech[v0.4.4].
- Conclusion: don't install google/gax 0.37.0
- google/cloud-text-to-speech v0.4.4 requires google/gax ^1.0 -> satisfiable by google/gax[1.0.0, 1.0.1, 1.0.2, 1.0.3].
- Can only install one of: google/gax[1.0.0, 0.37.0].
- Can only install one of: google/gax[1.0.1, 0.37.0].
- Can only install one of: google/gax[1.0.2, 0.37.0].
- Can only install one of: google/gax[1.0.3, 0.37.0].
- Installation request for google/gax (locked at 0.37.0) -> satisfiable by google/gax[0.37.0].
Installation failed, reverting ./composer.json to its original content.
How can I fix this? Is there any available libraries to download without using Composer?
It looks like either you or another dependency in your project also requires google/gax, but in an older version. You can find out why google/gax is locked at version 0.37.0 using the why command:
composer why google/gax
This should tell you wether it's installed as a root dependency, meaning you explicitly installed it or which other dependency requires it.
Then you have to find out whether there is a newer version of that dependency, so you can upgrade that dependency to be able to use a newer version of google/gax. If you determine updating it is safe just add both extensions to the require command or update the dependency first and then try requiring google/cloud-text-to-speech again.
Composer also provides a way to automatically update all dependencies for you, but this obviously risks introducing breaking changes from the updates, so use this with proper care:
--update-with-dependencies Allows inherited dependencies to be updated, except those that are root requirements.
--update-with-all-dependencies Allows all inherited dependencies to be updated, including those that are root requirements.
So running:
composer require --update-with-all-dependencies google/cloud-text-to-speech
should update your application in a way that it supports the required version of google/gax in order to install google/cloud-text-to-speech. This will likely result in other dependencies being updated and you can check the output to see which ones were affected.

Composer require gives errors while installing barryvdh/laravel-dompdf

I'm quite new with Laravel and wrote my first app.
I'm using Laravel 5.4 with PHP 7.1.5 on Windows, but when I run the composer require barryvdh/laravel-dompdf command, I get following issues. I have followed many "possible solutions" but still it is not working.
This is the error:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- Installation request for barryvdh/laravel-dompdf ^0.8.1 -> satisfiable by barryvdh/laravel-dom
pdf[v0.8.1].
- barryvdh/laravel-dompdf v0.8.1 requires dompdf/dompdf ^0.8 -> satisfiable by dompdf/dompdf[v0.
8.0, v0.8.1, v0.8.2] but these conflict with your requirements or minimum-stability.
Don't composer update. If you have dompdf/dompdf in your composer.json just update it, specifying 0.8.* as version and running
composer update dompdf/dompdf
then
composer require barryvdh/laravel-dompdf
--
Running a generic composer update will affect all your other dependencies you may want keep as they currently are.
All the changes affected by your composer update command are then recorded in your composer.lock file.
When you'll move your project somewhere else or you'll deploy it on a server for example, the composer install command will read the composer.lock file and will install the exact version of your dependencies which are recorded in it. So you'll be sure about the version of your dependencies.
Run this command
composer require barryvdh/laravel-dompdf "^0.8.2" .
Delete your composer.lock file and run:
composer install
Check then dompdf/dompdf may updated e.g. 0.7.* or ~0.7.0
composer update;
composer require barryvdh/laravel-dompdf;

Categories