{"id":42284833,"url":"https://github.com/joseph-montanez/raylib-php","last_synced_at":"2026-01-27T09:03:33.626Z","repository":{"id":53791737,"uuid":"128349014","full_name":"joseph-montanez/raylib-php","owner":"joseph-montanez","description":"PHP 8 Bindings to raylib","archived":false,"fork":false,"pushed_at":"2023-08-17T13:20:37.000Z","size":21528,"stargazers_count":150,"open_issues_count":4,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2023-11-07T20:16:05.897Z","etag":null,"topics":["linux","macos","php-extension","raylib","raylib-php","windows"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joseph-montanez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-06T05:35:41.000Z","updated_at":"2023-10-08T17:18:44.000Z","dependencies_parsed_at":"2023-01-25T05:31:19.867Z","dependency_job_id":null,"html_url":"https://github.com/joseph-montanez/raylib-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":null,"template_full_name":null,"purl":"pkg:github/joseph-montanez/raylib-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2Fraylib-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2Fraylib-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2Fraylib-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2Fraylib-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joseph-montanez","download_url":"https://codeload.github.com/joseph-montanez/raylib-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2Fraylib-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28810468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","macos","php-extension","raylib","raylib-php","windows"],"created_at":"2026-01-27T09:03:13.437Z","updated_at":"2026-01-27T09:03:33.615Z","avatar_url":"https://github.com/joseph-montanez.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# raylib-php\n\nPHP 8.x bindings for RayLib, a simple and easy-to-use library to learn video g\n\nThis is currently a work-in-progress and bindings are not complete and are likely to change.\n\n- raylib.h - See [Not yet implemented](#not-yet-implemented)\n- raymath.h - TODO Extra mathy stuff\n- raygui.h - TODO API for drawing GUI\n- physac.h - TODO More complex collision detection, more than built-in collision detection\n\n## Other PHP RayLib Bindings\n\n- [PHP Raylib FFI](https://github.com/nawarian/raylib-ffi) - Uses PHP's built-in FFI (Foreign Function Interface) to\n  connect directly to the shared RayLib.dll/.so file. This will be slower than a native binding.\n\n## Isn't PHP A Terrible Choice For Games?\n\nHere are some common misconceptions:\n\n- **PHP has no multi-threading**. There are native PHP extensions to enable this, pThreads and now a easier way to tackle this issue Parallel - https://github.com/krakjoe/parallel\n- **PHP is too slow**. Since PHP 7 a lot of things have gotten faster, so it can outperform Python and NodeJS in some area. PHP 8 now include JIT and provides even more performance.\n- **Object Oriented Programming in PHP is horrible**. Since PHP 5.4+ you get a lot of feature parity and since PHP 7 you now get type checking.\n- **Garbage Collection IS ... GARBAGE** - Until PHP 7.3 this was true. Running PHP in a tight loop for hours/days on end would hit a point where PHP could spend more time doing GC than anything else. This has been greatly improved.\n- **PHP Has No Code Reload** - Well not built-in. But, any language with `eval` can have code reloading. With that said I have code reloading using [SoftMocks](https://github.com/badoo/soft-mocks), but there is also a native PHP extension [Runkit7](https://github.com/runkit7/runkit7).\n  ![Code Reload](img/hot-reload.gif)\n\n## Example\n\n![Texture Image Loading](img/textures-image-loading.png)\n\n```php\n\u003c?php\n\nuse raylib\\Color;\nuse raylib\\Draw;\nuse raylib\\Text;\nuse raylib\\Timming;\nuse raylib\\Window;\n\n// Initialization\n//--------------------------------------------------------------------------------------\n$screenWidth  = 800;\n$screenHeight = 450;\n$lightGray    = new Color(245, 245, 245, 255);\n$gray         = new Color(200, 200, 200, 255);\n\nInitWindow($screenWidth, $screenHeight, \"raylib [core] example - basic window\");\n\nSetTargetFPS(60);                   // Set our game to run at 60 frames-per-second\n//--------------------------------------------------------------------------------------\n\n// Main game loop\nwhile (!WindowShouldClose())        // Detect window close button or ESC key\n{\n    // Update\n    //----------------------------------------------------------------------------------\n    // TODO: Update your variables here\n    //----------------------------------------------------------------------------------\n\n    // Draw\n    //----------------------------------------------------------------------------------\n\n    BeginDrawing();\n\n    ClearBackground($lightGray);\n\n    DrawText(\"Congrats! You created your first window!\", 190, 200, 20, $gray);\n\n    EndDrawing();\n    //----------------------------------------------------------------------------------\n}\n\n// De-Initialization\n//--------------------------------------------------------------------------------------\nCloseWindow();        // Close window and OpenGL context\n//--------------------------------------------------------------------------------------\n```\n\n## Autocomplete\n\nClasses and method calls are available via a stub repository. Its contains all the classes and methods so you get information on everything and anything implemented.\n\n![IDE Autocomplete](img/autocomplete.png)\n\nInstall via composer:\n\n    composer require joseph-montanez/raylib-php-stub\n\nMore information on the stubs can be found here at the repository [RayLib-PHP-Stubs](https://github.com/joseph-montanez/RayLib-PHP-Stubs)\n\n## License\n\nraylib-php is licensed under an unmodified zlib/libpng license, which is an OSI-certified,\nBSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.\n\n*Copyright (c) 2017 Joseph Montanez ([@joseph-montanez](https://twitter.com/shabb_jm))*\n\n## Binary Releases\n\n[Windows PHP Extension DLL](https://github.com/joseph-montanez/raylib-php/releases)\n\n## API Differences\n\nRaylib-PHP closely follows the RayLib's C-API with a few exceptions due to clashing function names:\n\n- ImageCopy is renamed to rlImageCopy due to collision with GDI\n- ImageCrop is renamed to rlImageCrop due to collision with GDI\n- Raylib static colors i.e RAYWHITE are renamed to raylib\\Color::RAYWHITE()\n\n## API Limitation\n\nThe PHP RayLib implementation has two glaring limitations.\n\n- Not all object properties are read and write, for example `/raylib/Image::width` is a read-only property but `/raylib/Vector2::x` is a read/write property. When you want to alter a property that is read-only there should be method calls such as `/raylib/Image::resize()` that will adjust the properties for you.\n- All RayLib object assignment i.e `$player-\u003eposition = $position` will **not copy** the variable but instead **link** the property. So if you want to copy the data instead, you need to use PHP's clone feature `clone` i.e `$player-\u003eposition = clone $position`.\n\n## How To Build PHP Extension\n\nWindows is by far the hardest platform to support and build for. Please use the binaries for Windows instead unless you want to commit fixes to this repo.\n\n### Linux\n\n#### Ubuntu 19.10+\n\n    sudo apt-get install -y libx11-dev xorg-dev\n\n#### Build\n\n    phpize\n    ./configure\n    make\n\n#### Mac OS\n\n    brew install raylib@4.5.0\n\nUnfortunately, macOS Brew via `brew install php@8.2` installs the non thread safe (nts) version which if you want to use \nparallels the multi-threaded extension for php, you will need to compile and install PHP manually.\n\n    git clone https://github.com/php/php-src.git\n    git checkout php-8.2.8\n    ./buildconf --force\n    ./configure --enable-zts --with-iconv=$(brew --prefix libiconv) --enable-opcache\n    make\n    sudo make install\n\n#### Build\n\n    phpize\n    ./configure\n    make\n\n### Windows\n\nWindows requires compiling with PHP sources (Currently Visual Studio 2019 needed), you will still get a .dll in the end.\n\nYou will need to also compile RayLib as well. At the time writing I am using Visual Studio 2019 compiler, since PHP 8 requires this. Once compiled paste the following files:\n\n(Please note your Raylib and PHP paths may be different)\n\n**Static Libs**\n\n    C:\\src\\raylib-4.5.0\\projects\\VS2022\\build\\raylib\\bin\\x64\\raylib.lib -\u003e C:\\php-sdk\\phpdev\\vc16\\x64\\deps\\lib\\raylib.lib\n\n**GLFW Includes**\n\n    C:\\src\\raylib-4.5.0\\src\\external\\glfw\\include\\GLFW\\glfw3.h -\u003e C:\\php-sdk\\phpmaster\\vc16\\x64\\deps\\include\\GLFW\\glfw3.h\n    C:\\src\\raylib-4.5.0\\src\\external\\glfw\\include\\GLFW\\glfw3native.h -\u003e C:\\php-sdk\\phpmaster\\vc16\\x64\\deps\\include\\GLFW\\glfw3native.h\n\n**RayLib Includes**\n\n    C:\\src\\raylib-4.5.0\\cmake-build-debug\\src\\raudio.h -\u003e C:\\php-sdk\\phpmaster\\vc15\\x64\\deps\\include\\raudio.h\n    C:\\src\\raylib-4.5.0\\cmake-build-debug\\src\\raylib.h -\u003e C:\\php-sdk\\phpmaster\\vc15\\x64\\deps\\include\\raylib.h\n    C:\\src\\raylib-4.5.0\\cmake-build-debug\\src\\raymath.h -\u003e C:\\php-sdk\\phpmaster\\vc15\\x64\\deps\\include\\raymath.h\n    C:\\src\\raylib-4.5.0\\cmake-build-debug\\src\\rlgl.h -\u003e C:\\php-sdk\\phpmaster\\vc15\\x64\\deps\\include\\rlgl.h\n\nOnce you have PHP \u0026 Raylib setup you can then compile the extension\n\n    %comspec% /k \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat\"\n    cd C:/php-sdk\n    phpsdk-vs16-x64.bat\n    cd phpdev\\vs16\\x64\\raylib-php\n    ..\\php-8.2.8-devel-vs16-x64-ts\\phpize.bat\n    configure\n    nmake\n\n## How To Run raylib PHP Extension\n\n### MacOS \u0026 Linux\n\n    php -dextension=modules/raylib.so examples/textures/textures_image_loading.php\n\n### Windows\n\n    php-win.exe -dextension=x64/Release_TS/php_raylib.dll examples/textures/textures_image_loading.php\n\n\n## Not Yet Implemented\n\nThese are methods that may be able to work later on with more development. For example callbacks are generally not \nsupported yet, but can be later.\n\n - GetRenderWidth\n - GetRenderHeight\n - TraceLog\n - SetTraceLogCallback\n - SetSaveFileDataCallback\n - SetLoadFileTextCallback\n - SetSaveFileTextCallback\n - SetLoadFileDataCallback\n - SaveFileData\n - MemFree\n - SetWindowOpacity\n - GetPixelColor\n - SetPixelColor\n - GenImageFontAtlas\n - UpdateMeshBuffer\n - SetShaderValue\n - SetShaderValueV\n - UpdateTexture\n - UpdateTextureRec\n - UpdateSound\n - UpdateAudioStream\n - SetAudioStreamCallback\n - AttachAudioStreamProcessor\n - DetachAudioStreamProcessor\n - AttachAudioMixedProcessor\n - DetachAudioMixedProcessor\n\n\n## Benchmarks\n\nUsing the Bunnymark textures 100,000 max, 144 frames per second. Any language / extension that hits 85 FPS is the limit\nof the GPU of the test machine. All run with \"Apple\" for **kind** (M1/M2) native architect.\n\nM1 Mac Mini - 16GB RAM - macOS Ventura 13.4.1\n\n - **Compiled** - Must be compiled to a binary to run the application\n - **Dynamic** - Can be interpreted for immediately running the application\n\n| Language                            | Typed    | Extension                  | FPS    | Memory | CPU  | GPU |\n|-------------------------------------|----------|----------------------------|--------|--------|------|-----|\n| C (CMake Release)                   | compiled | Native                     | 85 FPS | 47 MB  | 64%  | 90% |\n| Zig 0.11.0 (ReleaseFast) (Arena)    | compiled | raylib.zig                 | 85 FPS | 54 MB  | 60%  | 90% |\n| Rust (Release)                      | compiled | bitten2up/raylib-rs        | 85 FPS | 48 MB  | 67%  | 90% |\n| Go 2.20 (Release)                   | compiled | gen2brain/raylib-go        | 85 FPS | 55 MB  | 73%  | 90% |\n| C# 11 .Net 7                        | compiled | raylib-cs                  | 85 FPS | 68 MB  | 75%  | 90% |\n| Nim 2.0 (Release)                   | compiled | planetis-m/naylib          | 75 FPS | 49 MB  | 70%  | 90% |\n| Haxe 4.3.1 (no-debug, HXCPP_ARM64)* | compiled | raylib-haxe                | 47 FPS | 128 MB | 87%  | 66% |\n| NodeJS 20                           | dynamic  | node-raylib                | 44 FPS | 134 MB | 100% | 80% |\n| PHP 8.2 (Jit)                       | dynamic  | raylib-php                 | 41 FPS | 257 MB | 100% | 60% |\n| PHP 8.2                             | dynamic  | raylib-php                 | 27 FPS | 242 MB | 100% | 57% |\n| Ruby 3.2.2                          | dynamic  | vaiorabbit/raylib-bindings | 11 FPS | 144 MB | 100% | 50% |\n| Python 3.11**                       | dynamic  | raylib-python-cffi         | 10 FPS | 100 MB | 100% | 35% |\n| Lua (LuaJIT 2.1.0-beta3) (-O2)***   | dynamic  | TSnake41/raylib-lua        | 5 FPS  | 113 MB | 100% | 31% |\n\n1) ***Raylib-Haxe** does not compile out of the box and fixes are needed to run.\n\n2) ****Python - raylib-python-cffi** Uses FFI which is slower than a ctypes integration\n\n3) *****TSnake41/raylib-lua** Does not currently compile on Arm64 (M1/M2) out of the box, and JIT isn't working as expected on this platform as it should be faster.\n\nHonorable mentions:\n\n - **PyGame 2.5.1**: PyGame is completely software rendered and thus extremely slow, I wasn't even getting 1 FPS. You'll need to hand roll your own OpenGL\nrendering solution or leverage an additional library to get hardware acceleration. I tried sprite groups and no improvements.\n - **DragonRuby Game Toolkit 5.5**: DragonRuby is as slow as **raylib-python-cffi** coming in at 10 FPS. This is because DragonRuby does not \nhave batch rendering so if there are 100,000 sprites, that's 100,000 draw calls. It also forces you to render at 1280x720\nat 60 FPS, it's not possible to change this. There are render targets, but this doesn't reduce offscreen rendering.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseph-montanez%2Fraylib-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoseph-montanez%2Fraylib-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseph-montanez%2Fraylib-php/lists"}