hmennen90/php-vulkan

PHP Vulkan API bindings for 2D/3D graphics and GPU compute — built for PHPolygon engine

Maintainers

Package info

github.com/phpolygon/php-vulkan

Homepage

Issues

Language:C

Type:php-ext

Ext name:ext-vulkan

pkg:composer/hmennen90/php-vulkan

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

0.5.0 2026-03-23 07:39 UTC

This package is auto-updated.

Last update: 2026-04-12 15:40:37 UTC


README

PHP extension providing Vulkan API bindings for use with PHPolygon — a 2D/3D engine written in PHP.

Requirements

  • PHP >= 8.1
  • Vulkan SDK (LunarG / MoltenVK on macOS)
  • C compiler (gcc/clang)

Installation

macOS / Linux (From Source)

# Install Vulkan SDK (macOS)
brew install vulkan-sdk

# Build the extension
phpize
./configure --with-vulkan
make
make install

Add to your php.ini:

extension=vulkan

Windows

On Windows, no build toolchain is needed — PHP extensions are distributed as pre-compiled DLLs. Download the matching DLL from the Releases page (match your PHP version and thread-safety mode), then:

  1. Copy php_vulkan.dll into your PHP ext\ directory
  2. Add extension=vulkan to your php.ini
  3. Restart PHP / your web server

Quick Start

<?php
// Create Vulkan instance
$instance = new Vk\Instance(appName: 'MyApp');

// List GPUs
foreach ($instance->getPhysicalDevices() as $device) {
    echo $device->getName() . " (" . $device->getTypeName() . ")\n";
}

API Overview

All classes live in the Vk namespace:

Class Vulkan Object
Vk\Instance VkInstance
Vk\PhysicalDevice VkPhysicalDevice
Vk\Device VkDevice
Vk\Queue VkQueue
Vk\Buffer VkBuffer
Vk\DeviceMemory VkDeviceMemory
Vk\CommandPool VkCommandPool
Vk\CommandBuffer VkCommandBuffer
Vk\ShaderModule VkShaderModule
Vk\DescriptorSetLayout VkDescriptorSetLayout
Vk\DescriptorPool VkDescriptorPool
Vk\DescriptorSet VkDescriptorSet
Vk\PipelineLayout VkPipelineLayout
Vk\Pipeline VkPipeline
Vk\RenderPass VkRenderPass
Vk\Framebuffer VkFramebuffer
Vk\Image VkImage
Vk\ImageView VkImageView
Vk\Sampler VkSampler
Vk\Fence VkFence
Vk\Semaphore VkSemaphore
Vk\Swapchain VkSwapchainKHR
Vk\Surface VkSurfaceKHR

Constants are available via Vk\Vk::CONSTANT_NAME.

Examples

See the examples/ directory:

  • 01_enumerate_devices.php — List all GPUs and their properties
  • 02_compute_shader.php — Run a compute shader (multiply by 2)
  • 03_memory_info.php — Buffer creation and memory operations

License

MIT