Skip to content

Commit f2a5e0a

Browse files
committed
chore: add check if gmp php extension is installed
1 parent 0dacc9c commit f2a5e0a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Farbcode\LaravelEvm\Exceptions;
4+
5+
// Thrown when a mandatory PHP extension or runtime prerequisite is missing.
6+
class RequirementException extends EvmException {}
7+

src/LaravelEvmServiceProvider.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Illuminate\Contracts\Foundation\Application;
2222
use Spatie\LaravelPackageTools\Package;
2323
use Spatie\LaravelPackageTools\PackageServiceProvider;
24+
use Farbcode\LaravelEvm\Exceptions\RequirementException;
2425

2526
class LaravelEvmServiceProvider extends PackageServiceProvider
2627
{
@@ -39,8 +40,14 @@ public function configurePackage(Package $package): void
3940
]);
4041
}
4142

42-
public function packageRegistered()
43+
public function packageRegistered(): void
4344
{
45+
// Runtime environment guard: ensure GMP extension is loaded.
46+
// This package relies on big integer math (Keccak, RLP, transaction signing).
47+
if (! extension_loaded('gmp')) {
48+
throw new RequirementException('The GMP PHP extension is required for laravel-evm. Please enable it: e.g. install with `apt install php-gmp` or add `extension=gmp` to your php.ini and restart PHP-FPM / CLI.');
49+
}
50+
4451
$this->app->singleton(RpcClient::class, fn () => new RpcHttpClient(
4552
config('evm.rpc_urls'),
4653
(int) config('evm.chain_id', 137)

0 commit comments

Comments
 (0)