Sentry-laravel: error on PHP 7.3

Created on 9 Mar 2020  ·  13Comments  ·  Source: getsentry/sentry-laravel

Hi There,

I have this error since 3 days ago on sentry package version 1.5.0 and 1.7.0

  - Installing ocramius/package-versions (1.7.0): Loading from cache

Parse error: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /Users/moeinpaki/Projects/alopeyk/gitlab/instant-payment-service/vendor/ocramius/package-versions/src/PackageVersions/Installer.php on line 34

php version

PHP 7.3.11 (cli) (built: Dec 13 2019 19:21:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
support

Most helpful comment

yes exactly I did all of the steps above

now I added
"ocramius/package-versions": "1.5.0",

to my composer.json and it fixed the error

All 13 comments

Hi @moeinpaki, it looks like a PHP 7.4 version of ocramius/package-versions was installed. Did you create the composer.lock file on a host with PHP 7.4?

How to fix: https://github.com/getsentry/sentry-laravel/issues/334#issuecomment-596131576 (but use 7.3.0 instead of 7.2.0 ofcourse).

I tried that but still has error

You added the config to your composer.json and deleted your composer.lock file + vendor folder and re-ran composer install to generate a new composer.json and it still installes ocramius/package-versions:1.7.0?

Edit: This config:

    "config": {
        "platform": {
            "php": "7.3.0"
        }
    }

yes exactly I did all of the steps above

now I added
"ocramius/package-versions": "1.5.0",

to my composer.json and it fixed the error

Okay, I think something still was wrong since that platform hint shouldn't allow any dependencies to install with the wrong version, but it's hard for me to see why and help you with that, requiring a lower version is also a good solution for now.

Since this is not really a Sentry issue but more a Composer issue I'm closing this issue, feel free to reach back out if you run into other problems 👍

So because this package uses features which require php 7.4 to run. I can't install this from my host machine which runs php 7.3.9, nor can I install from the docker image for composer:latest, but I can't specify in the composer.json that I'd like a version which will run in a docker conainer that runs 7.4.5 because of this version mismatch.

maybe if this package stuck with basic language features instead of using the newest bells and whistles, nobody would be having these problems.

You're literally using features more advanced (features from 7.4) than the standard docker composer:latest image, which is on php 7.3 and all this package does, is some insallation logic which isn't even needed when running my app. It's not even critical to running my app, but it's blocking composer from running successfully.

I get that it's super duper cool to use new awesome language features, but this is just causing unnecessary chaos.

I have code which runs on every php version from version 5 upwards and it's not sexy, nor cool, but it's does the job it needed to do.

Do your super duper cool stuff in other packages that aren't so critical or core that you end up foisting this ridiculous situation on people.

Hi @christhomas,

The problem is when a composer.lock was generated on a PHP version higher than the one you are going to run composer install on. This should always be prevented if possible and in the comments above I've mentioned and linked to documentation to correctly hint the PHP version you want composer to consider when generating a composer.lock file in case you (or a colleague) runs a higher PHP version but updates the composer.lock file.

You can install this package without any issues on PHP 7.3 and the code in this package is compatible with PHP 7.1 and higher.


Click here for the installation output on PHP 7.3

~ ❯ php -v
PHP 7.3.17 (cli) (built: Apr 29 2020 17:23:10) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.17, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.17, Copyright (c) 1999-2018, by Zend Technologies
~ ❯ laravel new sentry-test && cd sentry-test
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 92 installs, 0 updates, 0 removals
  - Installing doctrine/inflector (2.0.1): Loading from cache
  - Installing doctrine/lexer (1.2.0): Loading from cache
  - Installing dragonmantank/cron-expression (v2.3.0): Loading from cache
  - Installing voku/portable-ascii (1.4.10): Loading from cache
  - Installing symfony/polyfill-ctype (v1.17.0): Loading from cache
  - Installing phpoption/phpoption (1.7.3): Loading from cache
  - Installing vlucas/phpdotenv (v4.1.5): Loading from cache
  - Installing symfony/css-selector (v5.0.8): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.2): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.17.0): Loading from cache
  - Installing symfony/var-dumper (v5.0.8): Loading from cache
  - Installing symfony/routing (v5.0.8): Loading from cache
  - Installing symfony/process (v5.0.8): Loading from cache
  - Installing symfony/polyfill-php72 (v1.17.0): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.17.0): Loading from cache
  - Installing symfony/mime (v5.0.8): Loading from cache
  - Installing symfony/polyfill-php73 (v1.17.0): Loading from cache
  - Installing symfony/http-foundation (v5.0.8): Loading from cache
  - Installing psr/event-dispatcher (1.0.0): Loading from cache
  - Installing symfony/event-dispatcher-contracts (v2.0.1): Loading from cache
  - Installing symfony/event-dispatcher (v5.0.8): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Installing symfony/error-handler (v5.0.8): Loading from cache
  - Installing symfony/http-kernel (v5.0.8): Loading from cache
  - Installing symfony/finder (v5.0.8): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/service-contracts (v2.0.1): Loading from cache
  - Installing symfony/console (v5.0.8): Loading from cache
  - Installing symfony/polyfill-iconv (v1.17.0): Loading from cache
  - Installing egulias/email-validator (2.1.17): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache
  - Installing ramsey/collection (1.0.1): Loading from cache
  - Installing brick/math (0.8.15): Loading from cache
  - Installing ramsey/uuid (4.0.1): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing opis/closure (3.5.1): Loading from cache
  - Installing symfony/translation-contracts (v2.0.1): Loading from cache
  - Installing symfony/translation (v5.0.8): Loading from cache
  - Installing nesbot/carbon (2.34.0): Loading from cache
  - Installing monolog/monolog (2.0.2): Loading from cache
  - Installing league/flysystem (1.0.68): Loading from cache
  - Installing league/commonmark (1.4.3): Loading from cache
  - Installing laravel/framework (v7.11.0): Loading from cache
  - Installing fideloper/proxy (4.3.0): Loading from cache
  - Installing asm89/stack-cors (1.3.0): Loading from cache
  - Installing fruitcake/laravel-cors (v1.0.6): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Loading from cache
  - Installing guzzlehttp/guzzle (6.5.3): Loading from cache
  - Installing nikic/php-parser (v4.4.0): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Loading from cache
  - Installing psy/psysh (v0.10.4): Loading from cache
  - Installing laravel/tinker (v2.4.0): Loading from cache
  - Installing scrivo/highlight.php (v9.18.1.1): Loading from cache
  - Installing filp/whoops (2.7.2): Loading from cache
  - Installing facade/ignition-contracts (1.0.0): Loading from cache
  - Installing facade/flare-client-php (1.3.2): Loading from cache
  - Installing facade/ignition (2.0.2): Loading from cache
  - Installing fzaninotto/faker (v1.9.1): Loading from cache
  - Installing hamcrest/hamcrest-php (v2.0.0): Loading from cache
  - Installing mockery/mockery (1.3.1): Loading from cache
  - Installing nunomaduro/collision (v4.2.0): Loading from cache
  - Installing webmozart/assert (1.8.0): Loading from cache
  - Installing phpdocumentor/reflection-common (2.1.0): Loading from cache
  - Installing phpdocumentor/type-resolver (1.1.0): Loading from cache
  - Installing phpdocumentor/reflection-docblock (5.1.0): Loading from cache
  - Installing phpunit/php-token-stream (3.1.1): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/type (1.1.3): Loading from cache
  - Installing sebastian/resource-operations (2.0.1): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): Loading from cache
  - Installing sebastian/object-enumerator (3.0.3): Loading from cache
  - Installing sebastian/global-state (3.0.0): Loading from cache
  - Installing sebastian/exporter (3.1.2): Loading from cache
  - Installing sebastian/environment (4.2.3): Loading from cache
  - Installing sebastian/diff (3.0.2): Loading from cache
  - Installing sebastian/comparator (3.0.2): Loading from cache
  - Installing phpunit/php-timer (2.1.2): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/php-file-iterator (2.0.2): Loading from cache
  - Installing theseer/tokenizer (1.1.3): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-code-coverage (7.0.10): Loading from cache
  - Installing doctrine/instantiator (1.3.0): Loading from cache
  - Installing phpspec/prophecy (v1.10.3): Loading from cache
  - Installing phar-io/version (2.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.3): Loading from cache
  - Installing myclabs/deep-copy (1.9.5): Loading from cache
  - Installing phpunit/phpunit (8.5.4): Loading from cache
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/lock
swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)
ramsey/uuid suggests installing ext-uuid (Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.)
ramsey/uuid suggests installing paragonie/random-lib (Provides RandomLib for use with the RandomLibAdapter)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing elasticsearch/elasticsearch (Allow sending log messages to an Elasticsearch server via official client)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongodb (Allow sending log messages to a MongoDB server (via driver))
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server (via library))
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (^2.6).)
laravel/framework suggests installing ext-memcached (Required to use the memcache cache driver.)
laravel/framework suggests installing ext-redis (Required to use the Redis cache and queue drivers (^4.0|^5.0).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).)
laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).)
laravel/framework suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).)
laravel/framework suggests installing nyholm/psr7 (Required to use PSR-7 bridging features (^1.2).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^4.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^4.0).)
laravel/framework suggests installing symfony/cache (Required to PSR-6 cache bridge (^5.0).)
laravel/framework suggests installing symfony/filesystem (Required to create relative storage directory symbolic links (^5.0).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use PSR-7 bridging features (^2.0).)
laravel/framework suggests installing wildbit/swiftmailer-postmark (Required to use Postmark mail driver (^3.0).)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
facade/ignition suggests installing laravel/telescope (^3.1)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
Generating optimized autoload files
31 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
> @php artisan key:generate --ansi
Application key set successfully.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
Application ready! Build something amazing.
sentry-test ❯ composer require sentry/sentry-laravel
Using version ^1.7 for sentry/sentry-laravel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 19 installs, 0 updates, 0 removals
  - Installing composer/package-versions-deprecated (1.8.0): Loading from cache
  - Installing psr/http-client (1.0.0): Loading from cache
  - Installing php-http/promise (v1.0.0): Loading from cache
  - Installing php-http/httplug (2.1.0): Loading from cache
  - Installing php-http/guzzle6-adapter (v2.0.1): Loading from cache
  - Installing psr/http-factory (1.0.1): Loading from cache
  - Installing http-interop/http-factory-guzzle (1.0.0): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing symfony/polyfill-uuid (v1.17.0): Loading from cache
  - Installing symfony/options-resolver (v5.0.8): Loading from cache
  - Installing clue/stream-filter (v1.4.1): Loading from cache
  - Installing php-http/message-factory (v1.0.2): Loading from cache
  - Installing php-http/message (1.8.0): Loading from cache
  - Installing php-http/discovery (1.7.4): Loading from cache
  - Installing php-http/client-common (2.1.0): Loading from cache
  - Installing jean85/pretty-package-versions (1.3.0): Loading from cache
  - Installing sentry/sentry (2.3.2): Loading from cache
  - Installing sentry/sdk (2.1.0)
  - Installing sentry/sentry-laravel (1.7.1): Loading from cache
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/polyfill-uuid suggests installing ext-uuid (For best performance)
php-http/message suggests installing zendframework/zend-diactoros (Used with Diactoros Factories)
php-http/message suggests installing slim/slim (Used with Slim Framework PSR-7 implementation)
php-http/discovery suggests installing puli/composer-plugin (Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.)
php-http/client-common suggests installing php-http/logger-plugin (PSR-3 Logger plugin)
php-http/client-common suggests installing php-http/cache-plugin (PSR-6 Cache plugin)
php-http/client-common suggests installing php-http/stopwatch-plugin (Symfony Stopwatch plugin)
Writing lock file
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: sentry/sentry-laravel
Package manifest generated successfully.
36 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

If you still need PHP 5 support you can use 0.8.x of this package which supports PHP 5.4 and up.

Please try to keep the comments constructive so we can try and help if it's needed or open up a new issue with information about your environment / problems.

Your answer won't give me the result that I want, nor will the comment that you've supplied. I also think it's appropriate to criticise bad decision making when I see it. Just because you don't agree, doesn't mean it's not worthy of comment. I also think it's appropriate to call out bad decisions because of how they affect people and to avoid the problems in future.

My runtime is 7.4.5. That's where my application will run. In my composer.json I have marked in the requirements

    "require": {
        "php": "^7.4.5",
    }

But the version of PHP on my Macbook is 7.3.9 and the version of PHP inside composer:latest docker image is also 7.3.

But the version of PHP I am requiring is 7.4.5. So composer will download a version of your library which is compatible with my requirements. So it downloads a version which is for 7.4.5 and then it crashes because Composer is being run with a version of PHP 7.3. The language constructs you're using to run your package are for 7.4. So it crashes because my runtime I'm using to install composer is not compatible with the version of your package which is now running on the wrong version of PHP.

The only solution I can do about this would be to upgrade my laptops PHP to 7.4.5. But that would mean that my laptop is no longer standard and in order to function, I would require 50 engineers also upgrade their laptops version of PHP to 7.4, despite running everything in a docker container, where it shouldn't matter.

So your decision to push for features which are compatible with 7.4 is just a bad decision. It means that unnecessary problems happen without good reason. You're package merely does some installation magic, it doesn't affect how my software runs on the server, once composer has finished, the job is over and your package does nothing.

But since other people have incorporated your package into their base requirements, it's meaning that this problem is exaggerated because I can't avoid it.

My comments about the software I wrote and how it is compatible with every version of PHP since version 5 was to prove a point that just because I could, in theory, upgrade that software to use version 7. There is little benefit to it since the code is already working, already simple, already useful. I don't need to use the latest bells and whistles in 7.4.5 because they would not improve the software, just make it less available for people who maybe are on lower versions of PHP.

I feel that you shouldn't chase the latest version of PHP with this software. You should lag behind because you have to realise other people installation systems are not the same as their runtime systems and you're decisions are causing chaos.

The solution I found, was to manually specify which version of this library I needed as in this comment, which is the ACTUAL SOLUTION: https://github.com/getsentry/sentry-laravel/issues/335#issuecomment-596517240

But if any software decides it wants to force me to use a higher version, I'm going to have an impossible problem to fix. Composer won't install and I'll be screwed and have to jump through a lot of hoops to continue working. Despite not even wanting to use your software in the first place. My software has no requirement for your software. But other dependencies do, so my hands are tied.

If you tell composer you require a minimum of PHP ^7.4.5 it will install packages that support PHP 7.4 and possibly only PHP 7.4 or higher.

So if you try to run that code on a machine that is running PHP 7.3 there is nothing we can to to make sure you get a package that supports PHP 7.3 because you explicitly define you require PHP ^7.4.5 in your composer.json.

Your composer requirements are wrong and should require ^7.3 because your platform is 7.3/7.4 (always require the lowest) since you want to be able to run your code on 7.3 on your laptop.

That's not true. Since code written using PHP 7.3 language features are compatible with servers running 7.4.

Also, the version of php that I use to install composer packages doesn't have to match the version of php that I'm using to run my software. Remember, your software does not run on my server. It runs on my development machine to install the composer packages.

Installing composer is just download versions of packages which my software will run at runtime. Your package doesn't run at runtime. It's just a tool to download composer packages to my machine.

Code written for PHP 4 is still largely compatible with servers running PHP 7.4, apart from if you use any deprecated features such as pass by reference, etc. But the second that I use "class" then PHP 4 won't run anymore and I need PHP 5 as a minimum.

So language features define the minimum version of PHP, not the maximum version of PHP (apart from things which are explicitly deprecated). So largely (because of the exception of deprecations), what you said is not correct.

So compatibility doesn't run equally in both directions. If you write code which is ONLY COMPATIBLE WITH PHP 7.4. Then I cannot run it on PHP 7.3, 7.2, 7.1, 7.0, etc.

But if you write code which is compatible with PHP 7.0, then it's compatible with every version of 7.0, all the way up to the very latest version.

So what you just wrote, is absolutely wrong.

Sorry in advance for being a bit blunt, but this issue comes up a lot:

I totally agree with @stayallive here. Running Composer on a platform which is not compatible with your own app is discouraged in any way. You MUST run Composer on the same environment where you work on your app, with the same language version and extensions installed.

If you're not, you're on your own, because Composer does a lot of stuff based on that. It checks if everything is in order, if any requirement is respected (extensions too!) from your project and all your dependencies, and it fails hard if not; it also runs plugins and after-install scripts. Symfony for example invokes the cache:clear command, which prepares your whole app, so that would crash and burn hard (if you do not use --no-scripts, but you still would have to invoke that later). So that's a big no-no.

All this leads me to deduce that you must be doing another thing that breaks Composer's flow: --ignore-platform-reqs. That flag is what makes you able to install you project (that you said it requires 7.4) using 7.3, totally disregarding all that I wrote above. Mind you, that will make your autoloader fail hard on Composer 2: https://php.watch/articles/composer-2#platoform-reqs

The right approach for you is to run Composer under PHP 7.4, either:

I personally always do the former, since the latter will always be susceptible to those issues.

Also, the version of php that I use to install composer packages doesn't have to match the version of php that I'm using to run my software. Remember, your software does not run on my server. It runs on my development machine to install the composer packages.

Installing composer is just download versions of packages which my software will run at runtime. Your package doesn't run at runtime. It's just a tool to download composer packages to my machine.

Nope it does. It's used at runtime to recover some package versions, for Sentry or for your dependencies if you enable the right integration.

The bottom line is that composer.json describes your application dependencies if you add to the require section of that dependency list PHP with a constraint of ^7.4.5 (minimum version of 7.4.5) you can't blame composer (or us) for it installing code that only runs on PHP 7.4 since your require section describes that that is OK to Composer.


It's clear you disagree with the above, and I think we will have to agree to disagree here and I'm happy you have found a solution that works for your use case.

You have voiced your concern and you are of course free to do so and I'm happy that you did so we can possibly address this in future if needed but I think we should stop the discussion here.

If in the future we can help you or there are issues/bugs with the (Laravel) Sentry SDK feel free to open up a _new_ issue and/or PR 👍

I would also add that jean85/pretty-package-versions has two new versions that can help here:

  • 1.3.0 relies on a fork of Ocramius' lib which was forked by the Composer's maintainers, and backports support to 7.0
  • 1.4.0 drops the dependency entirely BUT requires Composer 2.0, since the same feature is now present there

Note that you need at least Composer 1.10.6 to install this correctly, because of https://github.com/composer/composer/issues/8846

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IMM9O picture IMM9O  ·  5Comments

Dixens picture Dixens  ·  7Comments

andrey-helldar picture andrey-helldar  ·  7Comments

mx0r picture mx0r  ·  3Comments

errogaht picture errogaht  ·  8Comments