{"id":24017810,"url":"https://github.com/m3m0r7/php-os","last_synced_at":"2025-04-23T04:10:22.049Z","repository":{"id":248236715,"uuid":"827615726","full_name":"m3m0r7/php-os","owner":"m3m0r7","description":"An operating system written in PHP","archived":false,"fork":false,"pushed_at":"2024-07-31T13:02:13.000Z","size":1013,"stargazers_count":59,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T21:51:12.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m3m0r7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-12T02:51:12.000Z","updated_at":"2025-03-29T17:15:15.000Z","dependencies_parsed_at":"2024-07-31T16:28:04.616Z","dependency_job_id":null,"html_url":"https://github.com/m3m0r7/php-os","commit_stats":null,"previous_names":["m3m0r7/php-os"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3m0r7%2Fphp-os","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3m0r7%2Fphp-os/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3m0r7%2Fphp-os/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3m0r7%2Fphp-os/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m3m0r7","download_url":"https://codeload.github.com/m3m0r7/php-os/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366722,"owners_count":21418772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-01-08T09:53:10.634Z","updated_at":"2025-04-23T04:10:22.031Z","avatar_url":"https://github.com/m3m0r7.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-OS\n\nThe PHP-OS is implemented an Operating System written in PHP.\nThis is **not an emulator** for architectures; for example. i386, x86_64 and so on.\nThis project makes an assembly or image file directly for an operating system.\n\nMoreover, this is very ultra hyper maximum experimental implementation.\n\n## Requirements\n\n- PHP 8.3+\n- qemu\n- nasm\n- make\n\n## Notice\n\nIn currently status, this project only implements  **Intel x86_64** architecture.\nBut you can try this architecture with using QEMU on aarch (macOS M1, M2).\n\n## Screenshot\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./doc/demo3.png\"\u003e\n\u003c/p\u003e\n\n\n## Quick Start\n\n1. Install PHP-OS via composer.\n\n```\n$ composer require m3m0r7/php-os\n```\n\n2. Write an example code as `HelloWorld.php` as following.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$bootloader = new \\PHPOS\\OS\\Code(\n    new \\PHPOS\\Architecture\\Architecture(\n    // Use x86_64 architecture\n        \\PHPOS\\Architecture\\ArchitectureType::x86_64,\n    ),\n);\n\n// Initialize bootloader\n$bootloader\n    // Set 16 bit real mode\n    -\u003esetBits(\\PHPOS\\OS\\BitType::BIT_16)\n\n    // Set bootloader origin\n    -\u003esetOrigin(\\PHPOS\\OS\\OSInfo::MBR)\n\n    // Print Hello World into BIOS screen\n    -\u003eregisterService(\\PHPOS\\Service\\Kit\\Startup\\HelloWorld::class)\n\n    // Add bootloader signature\n    -\u003eregisterPostService(\\PHPOS\\Service\\BIOS\\Bootloader\\BootloaderSignature::class);\n\n// Bundle the code into an OS image\n$bundler = new \\PHPOS\\OS\\Bundler\\Bundler(\n    new \\PHPOS\\OS\\ConfigureOption(\n        __DIR__ . '/dist',\n        'php-os.img',\n        $bootloader,\n    ),\n);\n\n// Distribute Makefile and assembly into `dist` directory by the ConfigureOption\n$bundler-\u003edistribute();\n\n```\n\n3. Make with NASM instructions and build an OS image as following.\n\n```\n$ cd dist \u0026\u0026 make clean \u0026\u0026 make all\n```\n\n4. Start QEMU with qemu command as following.\n```\n$ qemu-system-x86_64 -drive file=./dist/build/php-os.img,format=raw\n```\n\n5. Show figure as following if you successfully to run the QEMU.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./doc/demo.png\"\u003e\n\u003c/p\u003e\n\n\nThe quick start example will generate an assembly file as following:\n```asm\n;\n;   _______  ____  ____  _______            ___     ______\n;  |_   __ \\|_   ||   _||_   __ \\         .'   `. .' ____ \\\n;    | |__) | | |__| |    | |__) |______ /  .-.  \\| (___ \\_|\n;    |  ___/  |  __  |    |  ___/|______|| |   | | _.____`.\n;   _| |_    _| |  | |_  _| |_           \\  `-'  /| \\____) |\n;  |_____|  |____||____||_____|           `.___.'  \\______.'\n;\n; Notice: This file is automatically generated by PHP-OS.\n;         Do not edit this file. We cannot be held responsible if this is edited and overwritten again.\n;\n\n\n[bits 16]\n\n[org 0x7c00]\n\nmain:\n  cli\n  xor ax, ax\n  xor bx, bx\n  mov ds, ax\n  mov es, ax\n  mov ss, ax\n  mov sp, 31744\n  sti\nmov esi, __php_var_SGVsbG8gV29ybGQh\ncall __php_PHPOS_Service_BIOS_IO_PrintConstantString\njmp __php_PHPOS_Service_BIOS_IO_PrintConstantString_PHPOS_Service_BIOS_IO_PrintConstantString_PrintDone\n__php_PHPOS_Service_BIOS_IO_PrintConstantString_PHPOS_Service_BIOS_IO_PrintConstantString_PrintCharacter:\n  mov ah, 14\n  mov ebx, 15\n  int 16\n  ret\n__php_PHPOS_Service_BIOS_IO_PrintConstantString:\n  lodsb\n  or al, al\n  jz __php_PHPOS_Service_BIOS_IO_PrintConstantString_PHPOS_Service_BIOS_IO_PrintConstantString_PrintDone\n  call __php_PHPOS_Service_BIOS_IO_PrintConstantString_PHPOS_Service_BIOS_IO_PrintConstantString_PrintCharacter\n  jmp __php_PHPOS_Service_BIOS_IO_PrintConstantString\n__php_PHPOS_Service_BIOS_IO_PrintConstantString_PHPOS_Service_BIOS_IO_PrintConstantString_PrintDone:\n  ret\nhlt\n\n__php_var_SGVsbG8gV29ybGQh:\n  db \"Hello World!\", 0\n\ntimes 510-($-$$) db 0\ndw 0xAA55\n```\n\n### Use VESA BIOS Extension\n\n#### Render a text\n```php\n\u003c?php\n\nuse PHPOS\\OS\\CodeInfo;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n//\n// Create kernel -----------------------------------------------------------------------------\n//\n\n$kernel = new \\PHPOS\\OS\\Code(\n    new \\PHPOS\\Architecture\\Architecture(\n        // Use x86_64 architecture\n        \\PHPOS\\Architecture\\ArchitectureType::x86_64,\n    ),\n);\n\n$image = new \\PHPOS\\Service\\Component\\Image\\Image(\n    // NOTE: Specify if you want to render an image path\n    //       Only available the file size belows 4KB.\n    __DIR__ . '/doc/logo.png',\n);\n$kernel\n    // Set code name\n    -\u003esetName('kernel')\n\n    // Set 16 bit real mode\n    -\u003esetBits(\\PHPOS\\OS\\BitType::BIT_16)\n\n    // Set kernel origin\n    -\u003esetOrigin(0x1000)\n\n    // Set compiled kernel size (floor(filesize / 512))\n    -\u003esetSectors((int) floor(CodeInfo::CODE_BLOCK_SIZE_BITS_16 / \\PHPOS\\OS\\OSInfo::PAGE_SIZE))\n\n    // Load VESA BIOS Extension\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\Standard\\Segment\\SetupSegments::class)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\VESABIOSExtension\\SetVESABIOSExtension::class)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\VESABIOSExtension\\SetVESABIOSExtensionInformation::class)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\VESABIOSExtension\\LoadVESAVideoAddress::class)\n\n    // Print \"Hello World!\" into VESA\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\IO\\PrintConstantString::class, 'Hello World!')\n\n    // Write code signature\n    -\u003eregisterPostService(\\PHPOS\\Service\\BIOS\\Disk\\CodeSignature::class);\n\n//\n// Create bootloader --------------------------------------------------------------------------\n//\n\n$bootloader = new \\PHPOS\\OS\\Code(\n    new \\PHPOS\\Architecture\\Architecture(\n        // Use x86_64 architecture\n        \\PHPOS\\Architecture\\ArchitectureType::x86_64,\n    ),\n);\n\n// Initialize bootloader\n$bootloader\n    // Set code name\n    -\u003esetName('bootloader')\n\n    // Set 16 bit real mode\n    -\u003esetBits(\\PHPOS\\OS\\BitType::BIT_16)\n\n    // Set bootloader origin\n    -\u003esetOrigin(\\PHPOS\\OS\\OSInfo::MBR)\n\n    // Setup segments (initialize registers for assembly)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\Standard\\Segment\\SetupSegments::class)\n\n    // Add loading something sector codes\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\System\\CallCode::class, $kernel)\n\n    // Add bootloader signature\n    -\u003eregisterPostService(\\PHPOS\\Service\\BIOS\\Bootloader\\BootloaderSignature::class);\n\n// Bundle each codes into an OS image\n$bundler = new \\PHPOS\\OS\\Bundler\\Bundler(\n    new \\PHPOS\\OS\\ConfigureOption(\n        __DIR__ . '/dist',\n        'php-os.img',\n        $bootloader,\n        [\n            $kernel,\n        ],\n    ),\n);\n\n// Distribute Makefile and assembly into `dist` directory by the ConfigureOption\n$bundler-\u003edistribute();\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"doc/demo2.png\" \u003e\n\u003c/p\u003e\n\n\n#### Render an image from inline\n```php\n\u003c?php\n\nuse PHPOS\\OS\\CodeInfo;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n//\n// Create kernel -----------------------------------------------------------------------------\n//\n\n$kernel = new \\PHPOS\\OS\\Code(\n    new \\PHPOS\\Architecture\\Architecture(\n        // Use x86_64 architecture\n        \\PHPOS\\Architecture\\ArchitectureType::x86_64,\n    ),\n);\n\n$image = new \\PHPOS\\Service\\Component\\Image\\Image(\n    // NOTE: Specify if you want to render an image path\n    //       Only available the file size belows 4KB.\n    __DIR__ . '/doc/logo.png',\n);\n$kernel\n    // Set code name\n    -\u003esetName('kernel')\n\n    // Set 16 bit real mode\n    -\u003esetBits(\\PHPOS\\OS\\BitType::BIT_16)\n\n    // Set kernel origin\n    -\u003esetOrigin(0x1000)\n\n    // Set compiled kernel size (floor(filesize / 512))\n    -\u003esetSectors(floor(CodeInfo::CODE_BLOCK_SIZE_BITS_16 / \\PHPOS\\OS\\OSInfo::PAGE_SIZE))\n\n    // Load VESA BIOS Extension\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\Standard\\Segment\\SetupSegments::class)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\VESABIOSExtension\\SetVESABIOSExtension::class)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\VESABIOSExtension\\SetVESABIOSExtensionInformation::class)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\VESABIOSExtension\\LoadVESAVideoAddress::class)\n\n    // Set render position\n    -\u003eregisterService(\n        \\PHPOS\\Service\\BIOS\\VESABIOSExtension\\Renderer\\SetRenderPosition::class,\n        $image-\u003ewidth(),\n        $image-\u003eheight(),\n        \\PHPOS\\Service\\Component\\VESA\\AlignType::CENTER_CENTER,\n    )\n\n    // Render an image\n    -\u003eregisterService(\n        \\PHPOS\\Service\\BIOS\\VESABIOSExtension\\Renderer\\RenderImageFromInline::class,\n        $image,\n    )\n\n    // Write code signature\n    -\u003eregisterPostService(\\PHPOS\\Service\\BIOS\\Disk\\CodeSignature::class);\n\n//\n// Create bootloader --------------------------------------------------------------------------\n//\n\n$bootloader = new \\PHPOS\\OS\\Code(\n    new \\PHPOS\\Architecture\\Architecture(\n        // Use x86_64 architecture\n        \\PHPOS\\Architecture\\ArchitectureType::x86_64,\n    ),\n);\n\n// Initialize bootloader\n$bootloader\n    // Set code name\n    -\u003esetName('bootloader')\n\n    // Set 16 bit real mode\n    -\u003esetBits(\\PHPOS\\OS\\BitType::BIT_16)\n\n    // Set bootloader origin\n    -\u003esetOrigin(\\PHPOS\\OS\\OSInfo::MBR)\n\n    // Setup segments (initialize registers for assembly)\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\Standard\\Segment\\SetupSegments::class)\n\n    // Add loading something sector codes\n    -\u003eregisterService(\\PHPOS\\Service\\BIOS\\System\\CallCode::class, $kernel)\n\n    // Add bootloader signature\n    -\u003eregisterPostService(\\PHPOS\\Service\\BIOS\\Bootloader\\BootloaderSignature::class);\n\n// Bundle each codes into an OS image\n$bundler = new \\PHPOS\\OS\\Bundler\\Bundler(\n    new \\PHPOS\\OS\\ConfigureOption(\n        __DIR__ . '/dist',\n        'php-os.img',\n        $bootloader,\n        [\n            $kernel,\n        ],\n    ),\n);\n\n// Distribute Makefile and assembly into `dist` directory by the ConfigureOption\n$bundler-\u003edistribute();\n```\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"doc/demo3.png\" \u003e\n\u003c/p\u003e\n\n\n### See examples\n\n- [Call a code in something sector](doc/example/01-call-code-in-something-sector/README.md)\n- [Render a square using VESA](doc/example/02-render-a-square-using-vesa/README.md)\n- [Render an image from disk using VESA](doc/example/03-render-an-image-from-disk-using-vesa/README.md)\n- [Enable A20 line and Transit to 32-bit mode](doc/example/04-enable-a20-line-and-transit-to-32bit-mode/README.md)\n- [Render a text](doc/example/05-render-a-text/README.md)\n- [GUI with menubar and fill background](doc/example/06-gui-with-menubar-and-fill-background/README.md)\n- [Capture and Print mouse position](doc/example/07-capture-and-print-mouse-position/README.md)\n- [Enable Text Mode](doc/example/08-enable-text-mode/README.md)\n- [Capture inputting keys](doc/example/09-capture-inputting-keys/README.md)\n\n## Test\n\n```\n$ ./vendor/bin/phpunit tests/\n```\n\n## Code formatting\n\n```\n$ ./vendor/bin/php-cs-fixer fix src/\n$ ./vendor/bin/php-cs-fixer fix tests/\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm3m0r7%2Fphp-os","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm3m0r7%2Fphp-os","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm3m0r7%2Fphp-os/lists"}