Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knubbe's avatar
Level 36

Laravel 6 and php 7.4 seeding problem

I update to php 7.4 and in mine laravel 6 project when I seed a class I get this error:

ErrorException : implode(): Passing glue string after array is deprecated. Swap the parameters

This is my 'problematic' factory class:

$factory->define(Complaint::class, function (Faker $faker) {
    return [
        'date' => Carbon::parse($faker->dateTimeBetween('-5 years', 'now'))->format('d.m.Y'),
        'type_of_complaint_id' => TypeOfComplaint::inRandomOrder()->first()->id,
        'center_id' => Center::inRandomOrder()->first()->id,
        'complainant' => $faker->name,
        'description' => $faker->text(50),
        'created_by' => User::inRandomOrder()->first()->id,
        'updated_by' => User::inRandomOrder()->first()->id,
    ];
});

What could be a problem?

0 likes
7 replies
tykus's avatar
tykus
Best Answer
Level 104

I would guess it might be the implementation of Faker's text helper - it generates random words and joins them into a string. Try replacing that description value with a string literal until Faker supports PHP 7.4

jlrdw's avatar

As I said on a similar question wait a little while before updating this stuff and let the other Technologies catch up, doesn't hurt to wait a month or two.

tykus's avatar

Or, contribute these fixes back to the open source packages that you use and rely on...

1 like
evzen's avatar

You can swap (in affect lines with implode command) glue and array. Example: return implode($words,' ') . '.'; to return implode(' ',$words) . '.';

ferares's avatar

The newest version of the fzaninotto/faker package solves this issue.

1 like
kkatwork's avatar

If you updated php to 7.4 .

run composer update.

It will update faker automatically.

1 like
NickSmithTech's avatar

I finally upgraded my Docker php container to 7.4 and encountered this implode() error while seeding.

I had to manually update my composer.json file as the project I am in at the moment is on an older framework version (6 where faker was 1.8.0):

   "require-dev": {
...
               "fzaninotto/faker": "~v1.9.2",
....
    }```

Please or to participate in this conversation.