Closed ViolanteCodes closed 2 years ago
@janondracek1 Hi, please, can you take a look at this error? Thank you
@ViolanteCodes
There was a slight issue of composer.lock
being included, which is overall a bad practice and is known to cause issues when installing across different environments. The mentioned file was generated on my environment of PHP 8.1.4.
I am currently unable to easily replicate your issue, as I do not have a clean Linux installation at my disposal, so I will try and guide you to resolve the mentioned issues.
From what I see in the dump you provided, you are missing vital extensions, that need to be manually configured via the mentioned php.ini
. As far as I know, this is not possible to be done automatically, as it varies from environment to environment.
To be exact, you are missing ext-dom
and ext-curl
, to enable those, you need to go into the folder of your PHP installation and open up php.ini
.
The ext-dom
extension is for XML manipulation and ext-curl
is for cURL, heavily utilized library for HTTP requests via PHP.
ext-curl
is provided by default, so in your php.ini
locate ;extension=curl
and remove the ;
character, which indicates a comment line.
As for the ext-dom
, it needs to be installed separately, look for php-xml
. Once the installation is complete, try to rerun composer-install
, it should go through.
If not, I will try to help you further.
@jakelumetta I wanted to loop you in here to see how you wanted to handle this.
If there is not way to automatically install these extensions, then we should probably have documentation in the readme (maybe a section at the bottom?) that at least points the user to how to easily resolve the issue or at least confirms that this is expected behavior and that the right step to take is to install the extensions.
I say this because when confronted with this error myself, although I thought maybe I should install these I also thought or maybe it's broken?
What do you think about having something in the installation instructions that says, "If you receive this message" (dependency related message), then drop to this section
below, which links to a quick walkthrough for people who are maybe a bit newer to PHP. That way, it doesn't break up the reading workflow for veteran developers, but it also confirms that these extensions are meant to be installed.
We could have a cleaner version of this maybe for the instructions?
Update @janondracek1
after running
sudo apt install php-xml
sudo apt-get install php-curl
I was able to run composer install
, however, I'm still seeing a number of deprecation warnings and notices. Is it not possible to resolve these? They're at the top and bottom of this message below.
**PHP Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Console/Helper/HelperSet.php on line 104
Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Console/Helper/HelperSet.php on line 104 Deprecation Notice: Optional parameter $schema declared before required parameter $path is implicitly treated as a required parameter in /usr/share/php/JsonSchema/Constraints/UndefinedConstraint.php:62 Deprecation Notice: Optional parameter $schema declared before required parameter $path is implicitly treated as a required parameter in /usr/share/php/JsonSchema/Constraints/UndefinedConstraint.php:108 Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/share/php/JsonSchema/Constraints/Constraint.php:48 Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:206 Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:206 Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:206 Deprecation Notice: Return type of Symfony\Component\Process\Process::getIterator($flags = 0) should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Symfony/Component/Process/Process.php:606 Deprecation Notice: Method ReflectionParameter::getClass() is deprecated in /usr/share/php/Composer/Repository/RepositoryManager.php:130 Deprecation Notice: Method ReflectionParameter::getClass() is deprecated in /usr/share/php/Composer/Repository/RepositoryManager.php:130 Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/ArrayRepository.php:206 Deprecation Notice: Return type of Composer\Repository\CompositeRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/Repository/CompositeRepository.php:139 Loading composer repositories with package information Deprecation Notice: Return type of Composer\DependencyResolver\Pool::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Pool.php:166 Installing dependencies (including require-dev) from lock file Deprecation Notice: Return type of Composer\DependencyResolver\RuleSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSet.php:114 Deprecation Notice: Return type of Composer\DependencyResolver\RuleSet::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSet.php:99 Deprecation Notice: Return type of Composer\DependencyResolver\Decisions::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Decisions.php:155 Deprecation Notice: Return type of Composer\DependencyResolver\Decisions::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Decisions.php:165 Deprecation Notice: Return type of Composer\DependencyResolver\Decisions::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Decisions.php:160 Deprecation Notice: Return type of Composer\DependencyResolver\Decisions::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Decisions.php:170 Deprecation Notice: Return type of Composer\DependencyResolver\Decisions::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Decisions.php:150 Deprecation Notice: Return type of Composer\DependencyResolver\Decisions::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/Decisions.php:145 Deprecation Notice: Return type of Composer\DependencyResolver\RuleSetIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSetIterator.php:36 Deprecation Notice: Return type of Composer\DependencyResolver\RuleSetIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSetIterator.php:46 Deprecation Notice: Return type of Composer\DependencyResolver\RuleSetIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSetIterator.php:41 Deprecation Notice: Return type of Composer\DependencyResolver\RuleSetIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSetIterator.php:89 Deprecation Notice: Return type of Composer\DependencyResolver\RuleSetIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/php/Composer/DependencyResolver/RuleSetIterator.php:70 Package operations: 123 installs, 0 updates, 0 removals
Why do we need ext-dom
and ext-curl
? Our API returns JSON data and we should not be doing raw curls requests, this project should utilize our PHP SDK to interact with the ButterCMS API: https://github.com/ButterCMS/buttercms-php
GuzzleHttp\Client
for HTTP requests.@jakelumetta This project indeed utilizes the PHP SDK you listed above.
ext-dom
and ext-curl
is needed by the dependencies of laravel/laravel
, as listed in the first provided dump.
I haven't touched dependencies of the starter Laravel project, except for adding the implementation for ButterCMS API and some development dependencies.
@jakelumetta please let me know if the adjust-the-readme solution works for you, per comments above :) thanks!
@janondracek1 Ah ok - if ext-dom
and ext-curl
are core to laravel and there's no way around it then I don't think we have much choice but to include them though it would be nice if we were able to exclude them if they are a little tricky to install 🤷♂️
@ViolanteCodes sure we can add a section to the bottom of the README. I would be curious if other devs on our team run into this issue as well. i.e. is this common?
@jakelumetta I tried trimming the sources as much as I could, without any direct impact and I am not entirely sure about dropping these dependencies.
@ViolanteCodes
If any issues arise, should I commit directly to master? Because I created a new PR #3 where I removed the mentioned package.lock, so try switching to that branch and trying running composer install
if the deprecation warnings still persist.
@jakelumetta @janondracek1
Sorry for a bit of a late reply on this but I've been down the rabbit hole with some reading to try to figure out what was going on here, why I was getting deprecation warnings for the code, etc.
When I checked out the PR that @janondracek1 posted, between the Fatal Argument errors on composer install
with -vvv
flag and the Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in /usr/share/php/Composer/DependencyResolver/DefaultPolicy.php:84
, I was able to chase down a thread https://github.com/composer/composer/issues/9097 which led me to believe the issue was with my version of composer.
I tried the composer self-update
command but was unable to update, which led to this thread https://stackoverflow.com/questions/37772798/unable-to-self-update-composer - apparently, the version of composer installed with apt
on linux is very outdated.
I uninstalled all the packages I'd installed thus far, including ext-dom
and ext-curl
, did a sudo apt remove composer
, and installed composer directly from source https://getcomposer.org/download/ as well as set composer on PATH.
I was then able to check out master branch, run composer install
, set my token, and successfully run the local server to launch the project, without downloading or installing any extra packages.
So, here are my conclusions and questions:
If you're having problems with installation, chances are good you need to update either your PHP version (this project requires 8.0.2) or your composer version (this project requires composer 2.3.5). Drop to #troubleshooting for more instructions
. composer install
command with an outdated version of composer, they'll get led down this rabbit-hole of installing dependency after dependency, deprecation warnings, etc--when the issue really is that they just need to update either php or composer. This is a real time-waster (and adds a ton of friction). It looks like all of the missing extensions and dependencies I was dealing with were all resolved by upgrading composer, so that is the step we should point users to.@ViolanteCodes If any issues arise, should I commit directly to master? Because I created a new PR #3 where I removed the mentioned package.lock, so try switching to that branch and trying running
composer install
if the deprecation warnings still persist.
I saw the PR but still had the same issues (per above) so I didn't merge it in--please continue to open PRs for changes so that I can evaluate and test changes before merging in, and thank you.
@ViolanteCodes I will update the README.md and re-include composer.lock in the linked PR. As far as I am aware, it is not possible to require one's version of composer.
@ViolanteCodes I will update the README.md and re-include composer.lock in the linked PR. As far as I am aware, it is not possible to require one's version of composer.
@janondracek1 we have already updated the language in the readme - sorry if that wasn't clear from commit history. I'm going to close this issue, thank you.
On
composer install
command, I'm seeing some deprecation warnings:This was immediately after installing PHP 8.0 (so version 8.0.17, which is less than pinned requirement of 8.0.2) https://share.getcloudapp.com/RBunZZ0m
But then once I'd updated to most recent support version + upgraded dependencies, I got this:
My apologies if this is all basic info to a veteran PHP developer, but can you walk me through what I'm supposed to do next? Is it expected that all of these warnings are going to resolve if I install the various packages one by one? Is there a way to have composer automatically install these packages? Ideally, we'd like to minimize warnings, etc., as much as possible and have people to be able to run "composer install" and maybe a few commands if necessary from command line and immediately jump into the project.