Back to Error Center

Call to undefined function

Error Message

Call to undefined function App\Jobs\str_slug()

Cause

Calling a function that doesn't exist or hasn't been imported. Common with string helpers that were moved to the Str facade in newer Laravel versions.

Solution

Use the Str facade for string functions: Str::slug(), Str::limit(), etc. Or import the helper function: use function Illuminate\Support\str_slug;.

Code Example

Fix
// Wrong - global helpers removed in newer versions
$slug = str_slug($title);

// Right - use Str facade
use Illuminate\Support\Str;
$slug = Str::slug($title);

// Or use the helper function
$slug = str($title)->slug()->toString();

Debugging Steps

  1. Check if the function exists in the current Laravel version
  2. Look for the function in the Str facade
  3. Check if the helper needs to be imported
  4. Review the Laravel upgrade guide for removed helpers

Prevention

Use the Str facade for string operations. Follow Laravel upgrade guides when upgrading versions. Test deprecated functions.