hmennen90/php-vulkan

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

Maintainers

Package info

github.com/hmennen90/php-vulkan

Language:C

Type:php-ext

Ext name:ext-vulkan

pkg:composer/hmennen90/php-vulkan

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.5.0 2026-03-23 07:39 UTC

This package is auto-updated.

Last update: 2026-03-23 08:39:13 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

# 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

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