"PHP Fatal error" on TYPO3 10 composer installation [solved]

Hi,

I was trying to install TYPO3 10 with composer and got a fatal php error. Significant message was this:

typo3cms install:generatepackagestates
PHP Fatal error: Declaration of TYPO3\CMS\Core\Database\Driver\PDOStatement::fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) must be compatible with Doctrine\DBAL\Driver\PDOStatement::fetchAll($mode = null, …$args) in /home/user/site-c10e/public/typo3/sysext/core/Classes/Database/Driver/PDOStatement.php on line 67

When I go to the directory and try to run update I also get this error message.

Here is the call I used for installation with the complete output.

$ php7.4 composer.phar create-project "typo3/cms-base-distribution:^10.4" site-c10e
Creating a "typo3/cms-base-distribution:^10.4" project at "./site-c10e"
Info from https://repo.packagist.org: #StandWithUkraine
Installing typo3/cms-base-distribution (v10.4.3)
  - Downloading typo3/cms-base-distribution (v10.4.3)
  - Installing typo3/cms-base-distribution (v10.4.3): Extracting archive
Created project in /home/user/site-c10e
Loading composer repositories with package information
Updating dependencies
Lock file operations: 93 installs, 0 updates, 0 removals
  - Locking doctrine/annotations (1.13.2)
  - Locking doctrine/cache (2.2.0)
  - Locking doctrine/dbal (2.13.9)
  - Locking doctrine/deprecations (v1.0.0)
  - Locking doctrine/event-manager (1.1.1)
  - Locking doctrine/instantiator (1.4.1)
  - Locking doctrine/lexer (1.2.3)
  - Locking egulias/email-validator (2.1.25)
  - Locking enshrined/svg-sanitize (0.15.4)
  - Locking guzzlehttp/guzzle (6.5.8)
  - Locking guzzlehttp/promises (1.5.1)
  - Locking guzzlehttp/psr7 (1.9.0)
  - Locking helhum/config-loader (v0.12.5)
  - Locking helhum/typo3-console (v6.7.4)
  - Locking lolli42/finediff (1.0.2)
  - Locking masterminds/html5 (2.7.5)
  - Locking nikic/php-parser (v4.14.0)
  - Locking phpdocumentor/reflection-common (2.2.0)
  - Locking phpdocumentor/reflection-docblock (5.3.0)
  - Locking phpdocumentor/type-resolver (1.6.1)
  - Locking psr/cache (1.0.1)
  - Locking psr/container (1.1.1)
  - Locking psr/event-dispatcher (1.0.0)
  - Locking psr/http-client (1.0.1)
  - Locking psr/http-factory (1.0.1)
  - Locking psr/http-message (1.0.1)
  - Locking psr/http-server-handler (1.0.1)
  - Locking psr/http-server-middleware (1.0.1)
  - Locking psr/log (1.1.4)
  - Locking ralouphie/getallheaders (3.0.3)
  - Locking symfony/cache (v4.4.43)
  - Locking symfony/cache-contracts (v1.1.12)
  - Locking symfony/config (v4.4.42)
  - Locking symfony/console (v4.4.43)
  - Locking symfony/dependency-injection (v4.4.43)
  - Locking symfony/event-dispatcher (v4.4.42)
  - Locking symfony/event-dispatcher-contracts (v1.1.12)
  - Locking symfony/expression-language (v4.4.43)
  - Locking symfony/filesystem (v4.4.42)
  - Locking symfony/finder (v4.4.41)
  - Locking symfony/http-foundation (v4.4.43)
  - Locking symfony/inflector (v4.4.37)
  - Locking symfony/mailer (v4.4.43)
  - Locking symfony/mime (v4.4.43)
  - Locking symfony/polyfill-ctype (v1.26.0)
  - Locking symfony/polyfill-intl-icu (v1.26.0)
  - Locking symfony/polyfill-intl-idn (v1.26.0)
  - Locking symfony/polyfill-intl-normalizer (v1.26.0)
  - Locking symfony/polyfill-mbstring (v1.26.0)
  - Locking symfony/polyfill-php72 (v1.26.0)
  - Locking symfony/polyfill-php73 (v1.26.0)
  - Locking symfony/polyfill-php80 (v1.26.0)
  - Locking symfony/polyfill-php81 (v1.26.0)
  - Locking symfony/process (v4.4.41)
  - Locking symfony/property-access (v4.4.41)
  - Locking symfony/property-info (v4.4.42)
  - Locking symfony/routing (v4.4.41)
  - Locking symfony/service-contracts (v1.1.12)
  - Locking symfony/var-exporter (v4.4.43)
  - Locking symfony/yaml (v4.4.43)
  - Locking typo3/class-alias-loader (v1.1.3)
  - Locking typo3/cms-about (v10.4.30)
  - Locking typo3/cms-backend (v10.4.30)
  - Locking typo3/cms-belog (v10.4.30)
  - Locking typo3/cms-beuser (v10.4.30)
  - Locking typo3/cms-cli (2.0.0)
  - Locking typo3/cms-composer-installers (v3.1.2)
  - Locking typo3/cms-core (v10.4.30)
  - Locking typo3/cms-dashboard (v10.4.30)
  - Locking typo3/cms-extbase (v10.4.30)
  - Locking typo3/cms-extensionmanager (v10.4.30)
  - Locking typo3/cms-felogin (v10.4.30)
  - Locking typo3/cms-filelist (v10.4.30)
  - Locking typo3/cms-fluid (v10.4.30)
  - Locking typo3/cms-fluid-styled-content (v10.4.30)
  - Locking typo3/cms-form (v10.4.30)
  - Locking typo3/cms-frontend (v10.4.30)
  - Locking typo3/cms-impexp (v10.4.30)
  - Locking typo3/cms-info (v10.4.30)
  - Locking typo3/cms-install (v10.4.30)
  - Locking typo3/cms-recordlist (v10.4.30)
  - Locking typo3/cms-rte-ckeditor (v10.4.30)
  - Locking typo3/cms-seo (v10.4.30)
  - Locking typo3/cms-setup (v10.4.30)
  - Locking typo3/cms-sys-note (v10.4.30)
  - Locking typo3/cms-t3editor (v10.4.30)
  - Locking typo3/cms-tstemplate (v10.4.30)
  - Locking typo3/cms-viewpage (v10.4.30)
  - Locking typo3/html-sanitizer (v2.0.14)
  - Locking typo3/phar-stream-wrapper (v3.1.7)
  - Locking typo3/symfony-psr-event-dispatcher-adapter (v1.0.0)
  - Locking typo3fluid/fluid (2.7.1)
  - Locking webmozart/assert (1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 93 installs, 0 updates, 0 removals
  - Downloading typo3/cms-composer-installers (v3.1.2)
  - Downloading typo3/class-alias-loader (v1.1.3)
  - Downloading psr/cache (1.0.1)
  - Downloading doctrine/lexer (1.2.3)
  - Downloading doctrine/annotations (1.13.2)
  - Downloading doctrine/cache (2.2.0)
  - Downloading doctrine/deprecations (v1.0.0)
  - Downloading doctrine/event-manager (1.1.1)
  - Downloading doctrine/instantiator (1.4.1)
  - Downloading enshrined/svg-sanitize (0.15.4)
  - Downloading symfony/polyfill-php72 (v1.26.0)
  - Downloading symfony/polyfill-intl-normalizer (v1.26.0)
  - Downloading symfony/polyfill-intl-idn (v1.26.0)
  - Downloading ralouphie/getallheaders (3.0.3)
  - Downloading psr/http-message (1.0.1)
  - Downloading guzzlehttp/psr7 (1.9.0)
  - Downloading guzzlehttp/promises (1.5.1)
  - Downloading guzzlehttp/guzzle (6.5.8)
  - Downloading typo3fluid/fluid (2.7.1)
  - Downloading symfony/event-dispatcher-contracts (v1.1.12)
  - Downloading psr/event-dispatcher (1.0.0)
  - Downloading typo3/symfony-psr-event-dispatcher-adapter (v1.0.0)
  - Downloading typo3/phar-stream-wrapper (v3.1.7)
  - Downloading psr/log (1.1.4)
  - Downloading symfony/polyfill-ctype (v1.26.0)
  - Downloading masterminds/html5 (2.7.5)
  - Downloading typo3/html-sanitizer (v2.0.14)
  - Downloading typo3/cms-cli (2.0.0)
  - Downloading symfony/yaml (v4.4.43)
  - Downloading symfony/polyfill-php80 (v1.26.0)
  - Downloading symfony/routing (v4.4.41)
  - Downloading symfony/polyfill-php81 (v1.26.0)
  - Downloading symfony/polyfill-php73 (v1.26.0)
  - Downloading symfony/polyfill-mbstring (v1.26.0)
  - Downloading symfony/polyfill-intl-icu (v1.26.0)
  - Downloading symfony/mime (v4.4.43)
  - Downloading psr/container (1.1.1)
  - Downloading symfony/service-contracts (v1.1.12)
  - Downloading symfony/event-dispatcher (v4.4.42)
  - Downloading egulias/email-validator (2.1.25)
  - Downloading symfony/mailer (v4.4.43)
  - Downloading symfony/http-foundation (v4.4.43)
  - Downloading symfony/finder (v4.4.41)
  - Downloading symfony/filesystem (v4.4.42)
  - Downloading symfony/var-exporter (v4.4.43)
  - Downloading symfony/cache-contracts (v1.1.12)
  - Downloading symfony/cache (v4.4.43)
  - Downloading symfony/expression-language (v4.4.43)
  - Downloading symfony/dependency-injection (v4.4.43)
  - Downloading symfony/console (v4.4.43)
  - Downloading symfony/config (v4.4.42)
  - Downloading psr/http-server-handler (1.0.1)
  - Downloading psr/http-server-middleware (1.0.1)
  - Downloading psr/http-factory (1.0.1)
  - Downloading psr/http-client (1.0.1)
  - Downloading nikic/php-parser (v4.14.0)
  - Downloading lolli42/finediff (1.0.2)
  - Downloading doctrine/dbal (2.13.9)
  - Downloading typo3/cms-core (v10.4.30)
  - Downloading symfony/inflector (v4.4.37)
  - Downloading symfony/property-info (v4.4.42)
  - Downloading symfony/property-access (v4.4.41)
  - Downloading phpdocumentor/reflection-common (2.2.0)
  - Downloading phpdocumentor/type-resolver (1.6.1)
  - Downloading webmozart/assert (1.11.0)
  - Downloading phpdocumentor/reflection-docblock (5.3.0)
  - Downloading typo3/cms-extbase (v10.4.30)
  - Downloading typo3/cms-fluid (v10.4.30)
  - Downloading typo3/cms-install (v10.4.30)
  - Downloading typo3/cms-frontend (v10.4.30)
  - Downloading typo3/cms-extensionmanager (v10.4.30)
  - Downloading typo3/cms-recordlist (v10.4.30)
  - Downloading typo3/cms-backend (v10.4.30)
  - Downloading symfony/process (v4.4.41)
  - Downloading helhum/config-loader (v0.12.5)
  - Downloading helhum/typo3-console (v6.7.4)
  - Downloading typo3/cms-about (v10.4.30)
  - Downloading typo3/cms-belog (v10.4.30)
  - Downloading typo3/cms-beuser (v10.4.30)
  - Downloading typo3/cms-dashboard (v10.4.30)
  - Downloading typo3/cms-felogin (v10.4.30)
  - Downloading typo3/cms-filelist (v10.4.30)
  - Downloading typo3/cms-fluid-styled-content (v10.4.30)
  - Downloading typo3/cms-form (v10.4.30)
  - Downloading typo3/cms-impexp (v10.4.30)
  - Downloading typo3/cms-info (v10.4.30)
  - Downloading typo3/cms-rte-ckeditor (v10.4.30)
  - Downloading typo3/cms-seo (v10.4.30)
  - Downloading typo3/cms-setup (v10.4.30)
  - Downloading typo3/cms-sys-note (v10.4.30)
  - Downloading typo3/cms-t3editor (v10.4.30)
  - Downloading typo3/cms-tstemplate (v10.4.30)
  - Downloading typo3/cms-viewpage (v10.4.30)
  - Installing typo3/cms-composer-installers (v3.1.2): Extracting archive
  - Installing typo3/class-alias-loader (v1.1.3): Extracting archive
  - Installing psr/cache (1.0.1): Extracting archive
  - Installing doctrine/lexer (1.2.3): Extracting archive
  - Installing doctrine/annotations (1.13.2): Extracting archive
  - Installing doctrine/cache (2.2.0): Extracting archive
  - Installing doctrine/deprecations (v1.0.0): Extracting archive
  - Installing doctrine/event-manager (1.1.1): Extracting archive
  - Installing doctrine/instantiator (1.4.1): Extracting archive
  - Installing enshrined/svg-sanitize (0.15.4): Extracting archive
  - Installing symfony/polyfill-php72 (v1.26.0): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.26.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.26.0): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-message (1.0.1): Extracting archive
  - Installing guzzlehttp/psr7 (1.9.0): Extracting archive
  - Installing guzzlehttp/promises (1.5.1): Extracting archive
  - Installing guzzlehttp/guzzle (6.5.8): Extracting archive
  - Installing typo3fluid/fluid (2.7.1): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v1.1.12): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing typo3/symfony-psr-event-dispatcher-adapter (v1.0.0): Extracting archive
  - Installing typo3/phar-stream-wrapper (v3.1.7): Extracting archive
  - Installing psr/log (1.1.4): Extracting archive
  - Installing symfony/polyfill-ctype (v1.26.0): Extracting archive
  - Installing masterminds/html5 (2.7.5): Extracting archive
  - Installing typo3/html-sanitizer (v2.0.14): Extracting archive
  - Installing typo3/cms-cli (2.0.0): Extracting archive
  - Installing symfony/yaml (v4.4.43): Extracting archive
  - Installing symfony/polyfill-php80 (v1.26.0): Extracting archive
  - Installing symfony/routing (v4.4.41): Extracting archive
  - Installing symfony/polyfill-php81 (v1.26.0): Extracting archive
  - Installing symfony/polyfill-php73 (v1.26.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.26.0): Extracting archive
  - Installing symfony/polyfill-intl-icu (v1.26.0): Extracting archive
  - Installing symfony/mime (v4.4.43): Extracting archive
  - Installing psr/container (1.1.1): Extracting archive
  - Installing symfony/service-contracts (v1.1.12): Extracting archive
  - Installing symfony/event-dispatcher (v4.4.42): Extracting archive
  - Installing egulias/email-validator (2.1.25): Extracting archive
  - Installing symfony/mailer (v4.4.43): Extracting archive
  - Installing symfony/http-foundation (v4.4.43): Extracting archive
  - Installing symfony/finder (v4.4.41): Extracting archive
  - Installing symfony/filesystem (v4.4.42): Extracting archive
  - Installing symfony/var-exporter (v4.4.43): Extracting archive
  - Installing symfony/cache-contracts (v1.1.12): Extracting archive
  - Installing symfony/cache (v4.4.43): Extracting archive
  - Installing symfony/expression-language (v4.4.43): Extracting archive
  - Installing symfony/dependency-injection (v4.4.43): Extracting archive
  - Installing symfony/console (v4.4.43): Extracting archive
  - Installing symfony/config (v4.4.42): Extracting archive
  - Installing psr/http-server-handler (1.0.1): Extracting archive
  - Installing psr/http-server-middleware (1.0.1): Extracting archive
  - Installing psr/http-factory (1.0.1): Extracting archive
  - Installing psr/http-client (1.0.1): Extracting archive
  - Installing nikic/php-parser (v4.14.0): Extracting archive
  - Installing lolli42/finediff (1.0.2): Extracting archive
  - Installing doctrine/dbal (2.13.9): Extracting archive
  - Installing typo3/cms-core (v10.4.30): Extracting archive
  - Installing symfony/inflector (v4.4.37): Extracting archive
  - Installing symfony/property-info (v4.4.42): Extracting archive
  - Installing symfony/property-access (v4.4.41): Extracting archive
  - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive
  - Installing phpdocumentor/type-resolver (1.6.1): Extracting archive
  - Installing webmozart/assert (1.11.0): Extracting archive
  - Installing phpdocumentor/reflection-docblock (5.3.0): Extracting archive
  - Installing typo3/cms-extbase (v10.4.30): Extracting archive
  - Installing typo3/cms-fluid (v10.4.30): Extracting archive
  - Installing typo3/cms-install (v10.4.30): Extracting archive
  - Installing typo3/cms-frontend (v10.4.30): Extracting archive
  - Installing typo3/cms-extensionmanager (v10.4.30): Extracting archive
  - Installing typo3/cms-recordlist (v10.4.30): Extracting archive
  - Installing typo3/cms-backend (v10.4.30): Extracting archive
  - Installing symfony/process (v4.4.41): Extracting archive
  - Installing helhum/config-loader (v0.12.5): Extracting archive
  - Installing helhum/typo3-console (v6.7.4): Extracting archive
  - Installing typo3/cms-about (v10.4.30): Extracting archive
  - Installing typo3/cms-belog (v10.4.30): Extracting archive
  - Installing typo3/cms-beuser (v10.4.30): Extracting archive
  - Installing typo3/cms-dashboard (v10.4.30): Extracting archive
  - Installing typo3/cms-felogin (v10.4.30): Extracting archive
  - Installing typo3/cms-filelist (v10.4.30): Extracting archive
  - Installing typo3/cms-fluid-styled-content (v10.4.30): Extracting archive
  - Installing typo3/cms-form (v10.4.30): Extracting archive
  - Installing typo3/cms-impexp (v10.4.30): Extracting archive
  - Installing typo3/cms-info (v10.4.30): Extracting archive
  - Installing typo3/cms-rte-ckeditor (v10.4.30): Extracting archive
  - Installing typo3/cms-seo (v10.4.30): Extracting archive
  - Installing typo3/cms-setup (v10.4.30): Extracting archive
  - Installing typo3/cms-sys-note (v10.4.30): Extracting archive
  - Installing typo3/cms-t3editor (v10.4.30): Extracting archive
  - Installing typo3/cms-tstemplate (v10.4.30): Extracting archive
  - Installing typo3/cms-viewpage (v10.4.30): Extracting archive
9 package suggestions were added by new dependencies, use `composer suggest` to see details.
Package symfony/inflector is abandoned, you should avoid using it. Use EnglishInflector from the String component instead.
Generating autoload files
Generating class alias map file
> typo3cms install:generatepackagestates
PHP Fatal error:  Declaration of TYPO3\CMS\Core\Database\Driver\PDOStatement::fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) must be compatible with Doctrine\DBAL\Driver\PDOStatement::fetchAll($mode = null, ...$args) in /home/user/site-c10e/public/typo3/sysext/core/Classes/Database/Driver/PDOStatement.php on line 67
Script typo3cms install:generatepackagestates handling the typo3-cms-scripts event returned with error code 255
Script @typo3-cms-scripts was called via post-autoload-dump

How can I fix this?

Best regards

edit: fixing a typo and making a sentence more understandable

It seems composer does not handle environments with multiple php versions by itself. The problem was, that even though composer was called with php7.4, it spawned processes of another php version.

I had to remove global alternative php that pointed to the newest version and then make sure that for the user who installs typo3 “php” defaults to php7.4

I guess I’ll refrain from using calls like

$ phpX.X composer...

in the future.

Side-note: Composer scripts invocation support the runtime variable @php, which uses the currently used PHP binary for the composer process, see Scripts - Composer for details

Scripts executable via CLI usually would fall back to the first PHP binary found in the corresponding environment due to #!/usr/bin/env php.