Skip to content

An open-source Minecraft: Java Edition server implementation, written in PHP.

License

Notifications You must be signed in to change notification settings

akemin-dayo/PHPCraft

Repository files navigation

PHPCraft

An open-source Minecraft: Java Edition server implementation, written in PHP.

What is PHPCraft?

PHPCraft is an open-source Minecraft: Java Edition server implementation, written in PHP.

That being said, PHPCraft is not intended to ever become a fully-functional, production-ready Minecraft server. It is simply a project that I work on for fun in my free time, because the idea of writing a Minecraft server implementation in PHP is just really amusing to me.

PHPCraft is a fork of Andrew Vy's HHVMCraft project.

※ Note: While HHVMCraft did (as the name would suggest) support HHVM, PHPCraft does not.


Which Minecraft versions are supported?

PHPCraft currently targets and supports Minecraft Beta b1.7.3 (Beta/pre-Netty Protocol 14), but you can connect to it with modern Minecraft versions using ViaProxy (recommended) or DirtMultiVersionsee below for screenshots!

I would have targeted and supported a modern Minecraft version if I were writing PHPCraft from scratch today, but since this is based off of an existing project that already had a large amount of work done for b1.7.3 already… supporting a modern version would have pretty much required a full rewrite and would be a lot of work for what is again, just a project I'm doing for fun in my free time.

(Maybe if I ever somehow just have too much free time some day, perhaps… ;P)

※ Regarding Bedrock Edition clients connecting using Geyser: Geyser may not work correctly with PHPCraft (all the blocks become invisible for some unknown reason). I'm not sure if this is still an issue with recent versions of Geyser, though.


Screenshots

A screenshot of Minecraft 1.17.1 connected to a PHPCraft server, showing a small house that was built from wood planks, a small pond, a tree, and various rose and dandelion flowers scattered about.

A modern Minecraft 1.17.1 client connected to a PHPCraft server. A Minecraft Beta b1.7.3 client was also connected to the PHPCraft server at the same time, viewing the same world.

(There are no doors or beds because those blocks do not work correctly yet in PHPCraft.)

A screenshot of Minecraft 1.17.1 connected to a PHPCraft server, showing the interior of a small house that was built from wood planks. It is later in the day, and the sunlight is filtering through the glass roof. There are two furnaces, some bookshelves, a crafting table, a music player, a chair (actually an oak stair block), and a single stone slab intended to represent a desk.

The same Minecraft 1.17.1 client connected to the same PHPCraft server, but at a later time of day.

More screenshots can be found in the screenshots folder that include more times of day, as well as screenshots of the Minecraft Beta b1.7.3 client that was also connected to the same PHPCraft server at the time.


How do I run PHPCraft?

Prerequisites

  • PHP 8.x (recommended, actively used in development) or PHP 7.4 (older versions also work, but are not recommended — see below for more information)
    • brew install php on macOS (requires Homebrew to be installed)
    • sudo apt install php on Debian-based Linux distributions
    • PHP for Windows
      • The "Non Thread Safe" version is sufficient for our purposes, as PHPCraft only uses PHP on the CLI, and not as part of a web server.
  • Composer

Running PHPCraft

git clone https://github.com/akemin-dayo/PHPCraft.git
cd PHPCraft
composer install
php start.php # ./start.php also works

You can configure various options in start.php, including (but not limited to) both the server port (25565 by default) and the IP address to bind to (0.0.0.0 by default)!

If you're using PHP 7…

Consider using PHP 8 instead. The only reason why PHPCraft supports PHP 7 because it just so happens to work. I actively develop and test against PHP 8.

That being said, if you really must use PHP 7 for some reason…

  • PHP 7.4: Run composer update -W.
  • PHP 7.3 (end-of-life): Run composer update -W.
  • PHP 7.2 (end-of-life): Run composer require --no-update --dev phpunit/phpunit ^8 and then composer update -W.
  • PHP 7.1 and 7.0 (end-of-life): Run composer require --no-update monolog/monolog ^1, composer require --no-update --dev phpunit/phpunit ^6, and then finally composer update -W.

※ IMPORTANT: Please be aware that PHP 7 is no longer actively supported. PHP 7.4 is only receiving critical security updates (no bug fixes), and PHP 7.3〜7.0 have completely reached end-of-life and are no longer receiving any security updates whatsoever.


Useful developer resources


License

Licensed under the MIT License.