ButterCMS / laravel-starter-buttercms

Drop-in proof-of-concept PHP/Laravel app, fully integrated with your ButterCMS account
http://laravel-starter-buttercms.herokuapp.com/
7 stars 1 forks source link

Deprecation Warnings: #2

Closed ViolanteCodes closed 2 years ago

ViolanteCodes commented 2 years ago

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:

butterenv) maria@maria-Galago-Pro:~/Programming/butter/starters/laravel-starter-buttercms$ composer install
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
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for tijsverkoyen/css-to-inline-styles 2.2.4 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.4].
    - tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 2
    - Installation request for phar-io/manifest 2.0.3 -> satisfiable by phar-io/manifest[2.0.3].
    - phar-io/manifest 2.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 3
    - Installation request for phpunit/php-code-coverage 9.2.15 -> satisfiable by phpunit/php-code-coverage[9.2.15].
    - phpunit/php-code-coverage 9.2.15 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 4
    - Installation request for phpunit/phpunit 9.5.19 -> satisfiable by phpunit/phpunit[9.5.19].
    - phpunit/phpunit 9.5.19 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 5
    - Installation request for spatie/laravel-ignition 1.1.1 -> satisfiable by spatie/laravel-ignition[1.1.1].
    - spatie/laravel-ignition 1.1.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
  Problem 6
    - Installation request for theseer/tokenizer 1.2.1 -> satisfiable by theseer/tokenizer[1.2.1].
    - theseer/tokenizer 1.2.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
  Problem 7
    - tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - laravel/framework v9.5.1 requires tijsverkoyen/css-to-inline-styles ^2.2.2 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.4].
    - Installation request for laravel/framework v9.5.1 -> satisfiable by laravel/framework[v9.5.1].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/8.1/cli/php.ini
    - /etc/php/8.1/cli/conf.d/10-opcache.ini
    - /etc/php/8.1/cli/conf.d/10-pdo.ini
    - /etc/php/8.1/cli/conf.d/20-calendar.ini
    - /etc/php/8.1/cli/conf.d/20-ctype.ini
    - /etc/php/8.1/cli/conf.d/20-exif.ini
    - /etc/php/8.1/cli/conf.d/20-ffi.ini
    - /etc/php/8.1/cli/conf.d/20-fileinfo.ini
    - /etc/php/8.1/cli/conf.d/20-ftp.ini
    - /etc/php/8.1/cli/conf.d/20-gettext.ini
    - /etc/php/8.1/cli/conf.d/20-iconv.ini
    - /etc/php/8.1/cli/conf.d/20-mbstring.ini
    - /etc/php/8.1/cli/conf.d/20-phar.ini
    - /etc/php/8.1/cli/conf.d/20-posix.ini
    - /etc/php/8.1/cli/conf.d/20-readline.ini
    - /etc/php/8.1/cli/conf.d/20-shmop.ini
    - /etc/php/8.1/cli/conf.d/20-sockets.ini
    - /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
    - /etc/php/8.1/cli/conf.d/20-sysvsem.ini
    - /etc/php/8.1/cli/conf.d/20-sysvshm.ini
    - /etc/php/8.1/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

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.

prokopsimek commented 2 years ago

@janondracek1 Hi, please, can you take a look at this error? Thank you

janondracek1 commented 2 years ago

@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.

ViolanteCodes commented 2 years ago

@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?

ViolanteCodes commented 2 years ago

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

jakelumetta commented 2 years ago

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

janondracek1 commented 2 years ago

@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.

ViolanteCodes commented 2 years ago

@jakelumetta please let me know if the adjust-the-readme solution works for you, per comments above :) thanks!

jakelumetta commented 2 years ago

@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?

janondracek1 commented 2 years ago

@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.

ViolanteCodes commented 2 years ago

@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:

ViolanteCodes commented 2 years ago

@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.

janondracek1 commented 2 years ago

@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 commented 2 years ago

@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.