wasmer php
1.1.0
Wasmer를 기반으로 하는 완전하고 성숙한 PHP용 WebAssembly 런타임입니다.
사용하기 쉬움 : wasmer API는 표준 WebAssembly C API를 모방합니다.
빠름 : wasmer 기본 속도 에 가깝게 가능한 한 빨리 WebAssembly 모듈을 실행합니다.
안전함 : WebAssembly에 대한 모든 호출은 빠르지만 더 중요한 것은 완전히 안전하고 샌드박스 처리된다는 것입니다.
라이브러리를 설치하려면 클래식을 따르십시오.
자식 클론 https://github.com/wasmerio/wasmer-phpcd wasmer-php/ext PHP화하다 ./configure --enable-wasmer 만들다 테스트메이크 설치하기
참고: Wasmer는 아직 Windows에서 작동하지 않습니다.
<?php 선언(strict_types=1);$engine = wasm_engine_new();$store = wasm_store_new($engine);$wasm = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'hello.wasm');$module = wasm_module_new($store, $wasm);function hello_callback() {echo '콜백 중...' . PHP_EOL;echo '> 안녕하세요!' . PHP_EOL;널을 반환;
}$functype = wasm_functype_new(new WasmVecValType(), new WasmVecValType());$func = wasm_func_new($store, $functype, 'hello_callback');wasm_functype_delete($functype);$extern = wasm_func_as_extern($func);$externs = 새로운 WasmVecExtern([$extern]);$instance = wasm_instance_new($store, $module, $externs);wasm_func_delete($func);$exports = wasm_instance_exports($instance);$run = wasm_extern_as_func($exports[0]);wasm_module_delete($module);wasm_instance_delete($instance);$results = wasm_func_call($run, new WasmVecVal());wasm_store_delete($store);wasm_engine_delete($engine); <?phpdeclare(strict_types=1);use Wasm;require_once __DIR__.'/../vendor/autoload.php';$engine = WasmEngine::new();$store = WasmStore::new($engine);$ wasm = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'hello.wasm');$module = WasmModule::new($store, $wasm);함수 hello_callback()
{echo '다시 전화하는 중...'.PHP_EOL;echo '> Hello World!'.PHP_EOL;return null;
}$functype = WasmFunctype::new(new WasmVecValType(), new WasmVecValType());$func = WasmModuleFunc::new($store, $functype, 'hello_callback');$extern = $func->asExtern(); $externs = new WasmVecExtern([$extern->inner()]);$instance = WasmModuleInstance::new($store, $module, $externs);$exports = $instance->exports();$run = $exports[0]->asFunc();$args = new WasmVecVal();$ 결과 = $run($args);이 예는 가장 기본적인 Wasm 사용 사례를 다룹니다. Wasm 모듈(텍스트 표현 형식)을 가져와서 인스턴스를 생성하고 내보낸 함수를 가져와 실행합니다.
전용 디렉터리에서 더 고급 예제를 살펴볼 수 있습니다.
절차적 API
객체지향 API
| 플랫폼 | 건축학 | 상태 |
|---|---|---|
| 리눅스 | amd64 | |
| 리눅스 | aarch64 | |
| 윈도우 | amd64 | |
| 다윈 | amd64 | |
| 다윈 | aarch64 |
| PHP | 상태 |
|---|---|
| 8.0 | |
| 7.4 | |
| 7.3 |
| 컴파일러 | 상태 |
|---|---|
| 크레인리프트 | |
| LLVM | |
| 싱글패스 |
| 엔진 | 상태 |
|---|---|
| 토종의 | |
| JIT | |
| 개체 파일 |
| 물체 | 상태 |
|---|---|
| 구성 | |
| 엔진 | |
| 가게 |
| 유형 | 상태 |
|---|---|
| 값 유형 | |
| 기능 유형 | |
| 글로벌 유형 | |
| 테이블 종류 | |
| 기억 유형 | |
| 외부 유형 | |
| 가져오기 유형 | |
| 내보내기 유형 |
| 물체 | 상태 |
|---|---|
| 발 | |
| 액자 | |
| 덫 | |
| 외국의 | |
| 기준 치수 | |
| 기능 | |
| 글로벌 | |
| 테이블 | |
| 메모리 | |
| 통근자 | |
| 사례 |
| 특징 | 상태 |
|---|---|
| 와트 | |
| 와시 | |
| 크로스 컴파일 |
전체 프로젝트는 MIT 라이센스를 따릅니다. LICENSE 파일을 읽어보세요.