spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
104 stars 29 forks source link

Upgrading from 2.9.3 to 2.12.3 gives "ParseError" #138

Closed joho1968 closed 2 years ago

joho1968 commented 2 years ago

Maybe it's just me, but this is what I get on an Ubuntu 20.04 (PHP 7.4.3):

(CLI command was "composer require spatie/statamic-responsive-images")

  Generating optimized autoload files
  Illuminate\Foundation\ComposerScripts::postAutoloadDump
  @php artisan package:discover --ansi

   ParseError

  syntax error, unexpected '|', expecting ';' or '{'

  at vendor/spatie/statamic-responsive-images/src/Tags/ResponsiveTag.php:123
    119▕             ? $this->params->get('placeholder')
    120▕             : config('statamic.responsive-images.placeholder', true);
    121▕     }
    122▕
 ➜ 123▕     private function getSrcSetFromBreakpoint(Breakpoint $breakpoint, string $format, bool $includePlaceholder): string|null
    124▕     {
    125▕         $isFormatIncluded = $this->params->has($format)
    126▕             ? $this->params->get($format)
    127▕             : config('statamic.responsive-images.' . $format, $format === 'webp');

      +1 vendor frames
  2   [internal]:0
      Composer\Autoload\ClassLoader::loadClass("Spatie\ResponsiveImages\Tags\ResponsiveTag")

      +10 vendor frames
  13  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
joho1968 commented 2 years ago

"Manually" selecting 2.10.0 works.

riasvdv commented 2 years ago

The latest version requires Statamic 3.3 which only supports PHP 8

austriker27 commented 2 years ago

The latest version requires Statamic 3.3 which only supports PHP 8

Unless I'm mistaken, it looks like the minimum PHP version for Statamic 3.3 is PHP 7.4 not PHP 8. (I know they recommend at least 8.1 with 3.3 - so I'll likely upgrade my PHP and avoid such an issue).

Docs Link: https://statamic.dev/upgrade-guide/3-2-to-3-3#php-version

image
ryandc commented 2 years ago

Is anyone else experiencing the same error as pointed out in the first comment?

I'm running Statamic on the latest version (3.3.54), and PHP 8.0.

ncla commented 2 years ago

PHP 8.0 should be fine. Make sure your CLI and your web server are running 8.0.

ryandc commented 2 years ago

Confirmed PHP version issue.

In case it's useful to anyone else, I was using MampPro with the host I setup for the site on PHP 8.0, but I kept getting weird issues.

I ended up using php please support:details which confirmed that the site was not using Mamp, and was using the default OSX php version. (7.something).

I ended up using brew to install PHP 8.0, and then switched the version. Following this article: https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-11-big-sur-and-catalina/

All down to my misunderstanding about Mamp and Laravel I think, but got there in the end.