Skip to content

Call to undefined function mb_split() - Missing mbstring extension in bundled PHP binary on macOS #22

@AbdenourTadjer33

Description

@AbdenourTadjer33

What were you trying to do?

I was trying to run a fresh NativePHP application on macOS

What happened?

Error in PHP:
  Call to undefined function Illuminate\Support\mb_split() (0) in ~/Projects/mixlab/vendor/laravel/framework/src/Illuminate/Support/Str.php:1685

The issue is that NativePHP's bundled PHP binary (from nativephp/php-bin) is missing the mbstring extension, which is required by Laravel's Str class.

How to reproduce the bug

  1. Install Laravel laravel new app
  2. composer require nativephp/desktop
  3. php artisan native:install
  4. php artisan native:run

Debug Output

{
    "Environment": {
        "PHP": {
            "Version": "8.3.26",
            "Path": "/Users/irongs/Library/Application Support/Herd/bin/php83"
        },
        "Laravel": {
            "Version": "11.46.1",
            "ConfigCached": false,
            "RoutesCached": false,
            "DebugEnabled": true
        },
        "Node": {
            "Version": "v22.17.1",
            "Path": "/Users/irongs/Library/Application Support/Herd/config/nvm/versions/node/v22.17.1/bin/node"
        },
        "NPM": {
            "Version": "11.4.2",
            "Path": "/Users/irongs/Library/Application Support/Herd/config/nvm/versions/node/v22.17.1/bin/npm"
        },
        "OperatingSystem": "Darwin"
    },
    "NativePHP": {
        "Versions": {
            "nativephp/desktop": "2.0.1.0",
            "nativephp/php-bin": "1.1.1.0"
        },
        "Configuration": {
            "Provider": "App\\Providers\\NativeAppServiceProvider",
            "BuildHooks": {
                "Pre": [],
                "Post": []
            },
            "NotarizationEnabled": false,
            "AzureTrustedSigningEnabled": false,
            "CustomPHPBinary": false
        }
    }
}

Which operating systems have you seen this occur on?

macOS

Notes

The bundled PHP binary is extracted from /vendor/nativephp/php-bin/bin/mac/x86/php-8.3.zip and is missing the mbstring extension. When running php artisan tinker with Herd's PHP, mb_split() works fine, confirming the issue is specific to NativePHP's bundled binary.
I verified this by directly testing the bundled PHP binary:
cd /Users/irongs/Projects/mixlab/vendor/nativephp/desktop/resources/build/php
./php ../../../../../../artisan tinker

Output:
Psy Shell v0.12.12 (PHP 8.3.15 — cli) by Justin Hileman
> mb_split()
   Error  Call to undefined function mb_split().

This confirms that the bundled PHP binary (PHP 8.3.15) does not have the mbstring extension compiled/enabled, while the same function works correctly with Herd's PHP installation.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions