A PHP extension to control GPIO on the RaspberryPi – my BrightonPHP talk

A while ago now (back in February!) I did a talk about writing an extension using Zephir to interact with the RaspberryPi’s GPIO.  The extension itself wraps around the wiringPi library and it makes it really easy to write PHP scripts that send output and gather input from the GPIO.

Here are the slides (use left/right arrow keys to navigate):

Full-sized version of the slides

Did you like this? Share it:

JW Player thumbnail creator now on Packagist and via Composer

Just a quick note to say that my thumbnail and VTT creator for JW Player, a script to help extract thumbnails from a video and present them in JW Player a a toolbar preview, has now got the ability to be included in your project via composer. Just use:

composer require amnuts/jwplayer-thumbnail-preview-generator

If you want, you can also browse for it on Packagist.

Did you like this? Share it:

phpiwire updated – now with PWM!

I’ve pushed a few changes to phpiwire can now use the PWM functions in wiringPi.  You can use either the hardware PWM pins or any of the GPIOs by using software PWM.  A couple new examples of how to do this have also been added to the repository.

With software PWM comes the requirement to include pthreads, so that’s also linked when you compile the zephir extension.

I’d recommend you do a full clean first before compiling with:

zephir fullclean
zephir install

Did you like this? Share it:

PHP South Coast 2015

I’ve just arrived back from the inaugural PHP South Coast Conference.  It was a really great event that seemed to go without a hitch, had a fantastic range of speakers and a nice bunch of people that attended.  So first of all, a really big thank you! to PHP Hampshire, BrightonPHP and PHP Dorset for putting on a top-notch event – you really wouldn’t have known it was their first one as everything seemed so professional! Continue reading PHP South Coast 2015

Did you like this? Share it:

Phpiwire: a PHP extension (written using Zephir) for controlling the Raspberry Pi GPIO

So it’s been a while since my lightening talk on Zephir and I realized I hadn’t really done anything to try to learn it a little more in-depth.  Coincidentally, I was recently going through a drawer and realized that one of my Raspberry Pi’s was in there just begging to be put to some use (seriously, I could practically hear it weep).  So I thought that the only thing to do was to attempt to write an extension using Zephir so that I could control the GPIO via PHP.  I mean, isn’t it obvious? Continue reading Phpiwire: a PHP extension (written using Zephir) for controlling the Raspberry Pi GPIO

Did you like this? Share it:

BrightonPHP lightning talk on Zephir

Yesterday I was one of four people to do a lightning talk at BrightonPHP. As anyone who knows me; I hate public speaking with a passion. Anything over, say, four people (usually including me) and I just like to sit there quietly and not say much. But encouraged by @coderabbi’s Wisdom as a Service talk he did at BrightonPHP in February (read: told at the train station by coderabbi that I had to do a talk) and the fact that it was a lightning talk so I didn’t actually have to speak that long, I presented a very brief, high-level overview of Zephir.

If you think any of this is inaccurate, needs tweaking, etc., then please let me know and I’ll happily update it accordingly.

Well done also to Rich, Rowan and Tristan for their very informative talks on joind.in, xml/json and selenium (respectively)…  Although I’m the only one that didn’t get an applause after their talk, so you’re all dead to me. 😛

Did you like this? Share it:

Opache gui update and now on Packagist

I’ve just pushed to github a big overhaul of the opcache gui script. It comes with a sweeping set of changes which also includes using react.js to power some of the interface to really enhance the real-time updates. (OK, it was really just an excuse for me to learn a little about react.js but I think it was worth it!)

I’ve also put the opcache gui and the php error log gui up on packagist – my first packages on there!  Check ’em out:

https://packagist.org/packages/amnuts/opcache-gui
https://packagist.org/packages/amnuts/phperror-gui

Did you like this? Share it:

‘Open in PhpStorm’ context menu for Windows

I’ve just started to use PhpStorm, which is a wonderful IDE. However, I wanted to make it even easier for myself to open files and folders. A context menu in Windows fits the bill quite nicely – just right-click on a folder and open in PhpStorm.

This batch file will do just that!

loading gist file...

Just set the path to whatever suits your system and then right-click and ‘run as administrator’ on the batch file.

Did you like this? Share it:
JWPlayer thumbnail preview generator

Create video thumbnail previews for JW Player

JWPlayer is a fantastic video player for the web. One of the great features it provides is the ability to show thumbnail previews of the video as you slide along the toolbar timeline, much the same way that YouTube and the like allow.

Generating the thumbnail images is not quite so easy unless you have ffmpeg installed and know a bit about the command line options. I got a little frustrated myself having to come up the with the command line magic whenever I needed it, and so the JW Player thumbnail preview generator was born!

It’s a simple command line tool, written in PHP, that allows you to whip up the thumbnails and generate the required VTT file with a command as simple as:

php thumbnails.php -i "/input/video.mp4"

OK, so you still need to have ffmpeg installed on your machine – not much I can do about that one, sorry! – but at least generating the files is now much easier!

You can generate the individual thumbnails or have them coalesced into  sprite sheet, and generate a random poster image. Full instructions are on my GitHub account; so go, fork, improve, and feel free to give any feedback.

Did you like this? Share it:

Effective, clean UI for viewing the PHP error log

Example usage

Recently at work I found myself trawling through the PHP error log file and found that all the lines of text were starting to blur after a while. Thinking there had to be a better way over viewing the log file, and following on from my single-file opcache viewer gui, I decided to knock out something for viewing the error log file as well.

With this single-file error log gui it will only show the error once and then tell you how many times it appears in the log. It will allow you to narrow down your search of errors by being able to hide the different types or sort in different ways, and it will also allow you to search results based on particular file paths.

I’ve pushed the code up to my GitHub account, so please feel free to fork and improve and/or give feedback.

Did you like this? Share it: