There is currently a lot of excitement around cryptocurrencies, with many making it rich and many more hoping to get rich quick. While speculating on cryptocurrencies is fun and (currently) profitable, cryptocurrencies are only part of the story of what makes this next technological innovation so ground-breaking.

At the heart of cryptocurrencies lies the concept of a blockchain, which, as the name implies, chains a number of blocks together, one after the other, with each block holding information whether transactions, smart contracts, data structures or anything else which needs to record something in an immutable way.

While revolutionary, the concept of the blockchain is quite simple; it is really just a linked list data structure. And it’s very easy to develop your own blockchain in pretty much any programming language you can think of.

There are already a number of tutorials on how to build blockchains in various languages and most cryptocurrency code is open sourced and available on Github, so simply browsing source is also a great way to learn how blockchains work. C, C++, Python and Java are the more popular languages for building blockchain technologies but there are also tutorials for Javascript, DotNet and others. Surprisingly, I was unable to turn up a PHP blockchain implementation so I thought I would develop a simple one myself with the aim of better understanding how the blockchain works. Using a blockchain tutorial for Javascript, I coded up a PHP-based blockchain and have made it publicly available on Github in the hope that others may also find it of interest.

Currently the implementation is very basic but it highlights the principles of a block chain; blocks can hold arbitrary data, are linked together via a blockchain and cannot be changed without corrupting the entire chain. I have also added basic mining to demonstrate the concept of proof-of-work.

Future developments on the PHP Blockchain roadmap might include:

  • Transactions
  • Wallets
  • Distributed architecture
  • Consensus

This is an open source project aimed at PHP programmers who wish to build a PHP-specific blockchain, so feel free to fork the code, make your own changes and contribute them back.

Some additional material for working with blockchains:
Python-focussed blockchain development with transaction and consensus coding examples.
Information about merkle trees which form the basis of transaction management.
The bitcoin code. While is C++ it is quite easy to follow the overall structure of a blockchain-based crypotcurrency.

Do NOT follow this link or you will be banned from the site!