Posts Tagged ‘github’

Word Search, a PHP library

Sunday, June 5th, 2016 | News, Programming

Have you ever been working on a PHP project and found yourself thinking “what I really need is a way to quickly and easily drop a word search in to this code”? The answer is almost certainly, no.

However, while working on Learn Finnish I found myself in exactly this situation. Being unable to find a good library, I wrote one and published it on GitHub. It is freely available under the MIT license and registered with Composer:

composer require xmeltrut/WordSearch "^1.0"

All you have to do is pass in some words and it will generate a puzzle. It supports horizontal and vertical words, intersecting words and comes with two alphabets by default: English and Finnish.

If you’re feeling generous, head over to GitHub and star it.

word-search

Travis CI

Monday, May 30th, 2016 | Programming, Tech

travis-ci

Travis CI is a cloud-based continuous integration tool. Notably, it is also free for open source projects. They do paid subscriptions as well if there is a private repo you want to test. If you just want to test a public GitHub project though, it’s free and really easy to set up.

You can log in with your GitHub account. Once you have done this, you are given a list of your projects and you can turn on Travis CI for each one individually. Using the GitHub hook, you can configure Travis CI to automatically run a build every time code is pushed to the repo.

It supports an array of different languages and platforms. To get up-and-running, you need to add a config file into your repo. This is pretty simple. Here one I am using for a PHP project:

language: php

php:
– ‘5.5’
– ‘5.6’
– ‘7.0’

install: composer install

This configures it to run it on three different versions of PHP, and install the dependencies before starting the test. It comes with many of the common PHP extensions already enabled, and an additional list of ones you can enable if you need them.

Badge Poser

Sunday, May 29th, 2016 | Programming

badge-poser

Badge Poser is an online tool that generates badges your PHP projects’ readmes. There is zero setup: it integrates with Packagist, so once you have your package setup you simply go to the website, enter your package name, and it generates the badges for you.

It then generates a series of Markdown for you to insert into your readme. This will then display anywhere where your readme is rendered: GitHub and Packagist for example.

Currently, it can generate badges for:

  • Stable and dev branch names
  • Total downloads
  • Monthly and daily downloads
  • License

Composer

Friday, June 28th, 2013 | Programming

These days, you’ll hear a lot of people talking about Composer in a conceited, condescending, and generally irritating way (you are using Composer, right?). It’s very annoying. But despite their best attempts their best efforts to put people off, Composer is actually a really useful tool.

It’s a dependency manager for PHP, allowing you to easily include libraries without having to bundle them in with your application – it’s essentially a package management system for PHP (kind of like PECL, but a lot more useful in many ways).

You can read about it here. Or here, in this blog post. What I should really say is, you can read more about it on the above website. Anyway…

Once you have it installed (and you can install it globally or just on a per project basis as an executable you can run), you can easily install all the depenencies in your project using:

composer install

This installs everything you need based on the project’s composer.json file, that you can save into your version controlled codebase. For example, here is the one I use for a Wing Commander project:

{
	"minimum-stability": "dev",
	"require": {
		"xmeltrut/wing-commander": "*"
	}
}

You can specify as many libraries as you need, and add version requirements for them too. There is also room for a “dev require” section – for example if you are using PHPUnit, you might want to install that library for your dev environment, but not your production clone.

Once you have everything installed, upgrading to the latest version of the libraries is easy:

composer update

Each time you download the libraries, it produces a composer.lock file that you can use to install your dependencies from – this records the version you are using, so you can generate your lock file on your dev environment, test it all works, then ensure your production environment has the same versions of all the libraries.

It also does dependency resolution. So if you try and install something with other dependencies – for example the Wing Commander library uses Flight and Mustache – it will automatically find this and download them too.

You can search for the packages you need on Packagist and while a lot of the libraries you will use are on Github, there is no coupling here – the dependency can specify any repository location and this is all handled transparently.

composer-logo

Formatter Library

Thursday, May 3rd, 2012 | Tech

If you’re like me, which seems unlikely as statistically you’re probably far more sensible, you’ll get really annoyed when the white spacing or indentation isn’t consistent within a file.

Because of this, I recently wrote a little Ruby script which would automatically clean up my CSS files and make them all nice and pretty. It’s now publicly available on Github if you want a copy.

At some point in the future I’m intending to do similar scripts for other file types – the SocietasPro codebase already has a similar system for PHP, though that only flags inconsistencies, it doesn’t correct them.

Leeds PHP User Group

Friday, March 30th, 2012 | Life, Tech

Last week, I finally made it down to the Leeds PHP User Group.

The meeting consisted of a talk by Lorna Mitchell on Git, Github and Open Source. It didn’t tell me anything that I didn’t already know, but it was interesting none the less. They also provide free food at their meetings, so I then regretted eating before I went 😀 .

By a perhaps unfortunate coincidence, the next day one of my friends sent me a contact they recommend I speak to about my career. The name rang a bell – turns out the recruitment agency had in fact been sponsoring the event and she was there – if only I had known 24 hours earlier I could have introduced myself in person! Still, there is always next month.