Mauserrifle.nl Tech Articles

    Projects     Archive     Contact

PHP-Minesweeper

Recently I’ve finished a project called PHP-Minesweeper. It’s an object-oriented PHP implementation of the game Minesweeper I’ve created to practice test-driven development. It was a success as it’s my first hobby project I actually bothered completing due to the fun with this way of developing. There were only minor bugs down the road and I implemented the front-end (HTML) within 30 minutes.

PHP Minesweeper

The source code and readme can be found at GitHub.

If you’re not familiar with git, you can download the project including all dependencies here.

The project requires 5.3. I’ve tested it with PHP 5.4 myself.

If you got PHP 5.4, playing is easy:

cd public
php -S localhost:8000

Open http://localhost:8000 in your browser.

For setting it up with apache2 or something else, make sure there is no base_dir restriction on the vhost.

To run the unit tests:

./vendor/bin/phpunit --colors tests

The project uses PHPUnit for the unit-tests, mustache for readable HTML templating and composer to tie these dependencies together. All files get loaded with composer‘s PSR-0 autoloader.

I hope anyone finds it useful as an example for the tests, templating, PSR-0 standard or object-oriented code. Whether you’re a inexperienced programmer or just new to PHP, this project should be a clear overview how to cleanly develop something within PHP.

If you have feedback, I would like to hear them as I love learning. Please comment!

If you liked this post, you can share it with your followers or follow me on Twitter!