21

So my Mailable view is throwing this error - and this is all I have on my hands. It was working fine while I was on Lumen 5.8, so my guess is that it happened after upgrading to Laravel 6.

Call to undefined function array_except() (View: /kunden/182801_60322/tu/uat/api/resources/views/mail/invite-employee.blade.php)

My blade file looks like this:

@extends('mail.master')

@section('content')
<tr>
    <td align="left" style="border: 1px solid #dddee5; border-bottom: 2px solid #cecfd9; padding; 20px;">
        <div class="padded">
            <p>
            {!! nl2br(e($data->message)) !!}
            </p>
        </div>
    </td>
<tr>
<tr>
    <td align="left" bgcolor="#eaeaf2" class="padded">
        <p style="margin-bottom: 5px;" class="cta-label">{{ $data->copy->click }}</p>
        <div class="cta-link">
            <a style="color: #337BE9;" class="cta-link--a" href="{{ $data->appUrl }}/{{ $data->route }}/{{ $data->verificationCode }}">{{ $data->appUrl }}/{{ $data->route }}/{{ $data->verificationCode }}</a>
        </div>
        <p style="font-size: 12px; margin-top: 10px;">{{ $data->copy->mistake }}</p>
    </td>
</tr>
@endsection

where obviously no part of the code is trying to call that function.

My composer.json looks like this:

{
    "name": "laravel/lumen",
    "description": "The Laravel Lumen Framework.",
    "keywords": ["framework", "laravel", "lumen"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.3.9",
        "laravel/lumen-framework": "^6.0",
        "vlucas/phpdotenv": "^3.3",
        "firebase/php-jwt": "^4.0",
        "guzzlehttp/guzzle": "^6.3",
        "illuminate/mail": "6.0.0",
        "phanan/cascading-config": "~2.0",
        "nesbot/carbon": "^2.0",
        "neitanod/forceutf8": "2.0.1",
        "maatwebsite/excel": "^3.1",
        "mpdf/mpdf": "^8.0",
        "tecnickcom/tcpdf": "^6.3",
        "laravel/helpers": "^1.1"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~5.0",
        "mockery/mockery": "~0.9"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/",
            "database/"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ]
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

where the laravel/helpers are also included now, separately. Nothing has helped so far. Any ideas what is causing this error?

Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
pop
  • 3,464
  • 3
  • 26
  • 43
  • Try `composer du` I think your class is not autoloaded. Because array_except() function is added in `laravel/helper` . You can find it in https://github.com/laravel/framework/blob/5.8/src/Illuminate/Support/helpers.php#L1071 – Prince Kumar Barnwal Oct 17 '19 at 12:32
  • 2
    `array_except` was deprecated in Laravel 5.8 (see https://laravel.com/docs/5.8/upgrade#support). You can use [`Arr::except()`](https://laravel.com/docs/6.x/helpers#method-array-except) instead. However, finding out where it's being used is a bit harder. Which line number is the error pointing to? – aynber Oct 17 '19 at 12:34
  • That's the thing - I have no line number, nothing. This message is all I get! And also, I do not explicitly call this method anywhere, as you see. These are some internal workings of the framework, I reckon. – pop Oct 17 '19 at 12:36
  • One thing you can try is `grep -R array_except resources/*` on the command line, from the root of the project. This will look for any instances of the function in all of the resource files. – aynber Oct 17 '19 at 12:38
  • Tried. Nothing. – pop Oct 17 '19 at 12:45
  • 1
    Hmm, interesting. Wonder if it was used as a map/helper somewhere else. Try `grep -R array_except * | egrep -v Illuminate`, see if it's somewhere else. That will find it anywhere in your project, including packages, that aren't part of the Laravel package – aynber Oct 17 '19 at 12:51

3 Answers3

75

Bit late to the party but:

as others have mentioned str_ and array_ helpers have been moved to a seperate package. If you don't wish to use that package after updating to laravel 6 you have to clear the views that were compiled using the old helper methods.

composer dump-autoload

then

php artisan view:clear

worked for me

craig-sen
  • 776
  • 5
  • 6
20

All str_ and array_ helpers have been moved to the new laravel/helpers Composer package and removed from the framework in the new version (6.0)

You can add helpers' package:

composer require laravel/helpers

as I see you added the package try dump-autoload:

composer dump-autoload

Upgrade 6.0 - String & Array Helpers Package

shahabphp
  • 369
  • 1
  • 2
  • 10
1

Ok, after @aynber suggested grep'ing everywhere, I've found that some of the views in storage/framework/views had the line array_except. After deleting everything within that directory and regenerating autoload.php as suggested by @sharhabphp it all worked fine again.

Thanks everyone!

pop
  • 3,464
  • 3
  • 26
  • 43