Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMP error on IPBlock run #75

Open
CasualCarlos opened this issue Nov 9, 2022 · 2 comments
Open

GMP error on IPBlock run #75

CasualCarlos opened this issue Nov 9, 2022 · 2 comments

Comments

@CasualCarlos
Copy link

Hi, today I installed the rlanvin/php-ip package via composer. Alongside that I also added the 'ext-gmp' to my composer.json:

"require": {
        "php": "^8.1",
        "ext-gmp": "*",
        "guzzlehttp/guzzle": "^7.2",
        "laravel/framework": "^9.18",
        "laravel/tinker": "^2.7",
        "league/flysystem-aws-s3-v3": "^3.0",
        "rlanvin/php-ip": "^3.0",
        "s1lentium/iptools": "^1.1",
        "spatie/laravel-ignition": "^1.3",
        "spatie/laravel-json-api-paginate": "^1.12"
    },

I added a call to the IPBlock like this:
$block = IPBlock::create($subnet->network.'/'.$subnetPrefix); but upon running I get this error message:

{
    "message": "Call to undefined function PhpIP\\gmp_init()",
    "exception": "Error",
    "file": "/var/www/html/vendor/rlanvin/php-ip/src/IP.php",
    "line": 196,
    "trace": [
        {
            "file": "/var/www/html/vendor/rlanvin/php-ip/src/IP.php",
            "line": 145,
            "function": "initGmpFromString",
            "class": "PhpIP\\IP",
            "type": "::"
        },

Is there anyone who knows what I've done wrong, or if this is just a bug in the package?

@haegar
Copy link
Contributor

haegar commented Nov 9, 2022

Are you sure you have the gmp extension enabled in your php.ini? (And perhaps also restarted apache/php-fpm)

The gpm_init function is defined by the gmp extension.
https://www.php.net/manual/en/function.gmp-init

@thannaske
Copy link

Also note that the ext-gmp requirement is only checked during the execution of the composer CLI which means only the PHP CLI's extensions are checked. If you are running multiple PHP versions and e.g. use php-fpm with a different PHP version for development purposes, you need to ensure that the extension is installed for that PHP version as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants