Can't Install Sample Data

Hello all,

Getting error when trying to install sample data:

count(): Argument #1 ($value) must be of type Countable|array, Closure given#0 /var/www/html/vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php(1202): count()

This is on a fresh install:

Ubuntu 22.04.1
Apache 2.4.52
PHP 8.1.2
MySQL 8.0.31
Magento 2.4.5-p1

Commands:

bin/magento deploy:mode:set developer
rm -rf generated/metadata/* generated/code/*
bin/magento c:c
bin/magento sampledata:deploy

It is at this point I’m getting the error.

Searching on the web it seems it is specifically a php8.1 error.

Can anyone suggest a fix?

Rather than fix this, I eventually avoided the problem all together by installing the sample data Via the GitHub Repository.

My Notes are below for anyone who has the same issue (obviously your paths may differ):

  1. Download from:
    https://github.com/magento/magento2-sample-data

    Click on “Latest”
    Assets > Source code (zip)

  2. In FileZilla:
    Copy magento2-sample-data-2.4.5-p1.zip TO /var/www/html/

  3. In CLI:

cd /var/www/html/
unzip magento2-sample-data-2.4.5-p1.zip
php -f magento2-sample-data-2.4.5-p1/dev/tools/build-sample-data.php -- --ce-source="/var/www/html/"
bin/magento setup:upgrade

We will not see any images without pre generating the product image cache
801 images (11 minutes)

php bin/magento catalog:image:resize

Thanks for posting this !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.