About 2 month ago, I found a nice service going by the name of pushover.net.
"Pushover makes it easy to send real-time notifications to your Android and iOS devices."
I had a look around for a decent PHP library, but could not find one. Most of them either had way too much code for such a simple task (it's basically a curl call), or where totally untested.
The library I built is very easy to use, and easy to setup. Below you can see an example of how to send a push notification:
include __DIR__ . '/vendor/autoload.php';
$pushover = new \Scottymeuk\Pushover\Client([
'token' => '',
$pushover->message = 'testing';
// Push Single
$push = $pushover->push($token);
// Push Multiple
$push = $pushover->pushMultiple([
The only downside to pushover.net is that the app costs, but with the amount of things I use it for, its been worth it.
If you wish to try out the library, then you can view it on Github.
Can't think of a use case? I built a quick CLI tool using the library to make it easy to push things to your mobile from your desktop. You can view that on Github too.
If you do happen to use any of these, please let me know in the comments below.
While reinstalling my Mac today I realised how easy it was to get PHP and Nginx working with Supervisor. However, if you asked me this the first time i setup my Mac, I probably would have screamed at you for not helping me.
Supervisor allows you to manage any process with ease, and through a simple web ui. You can manage anything from PHP itself, to long running scripts. We use it on romhut.com to manage the upload workers which are written in PHP, its very powerful to use, once you know.
I figured I'd write a blog post to explain how simple it is, and act as a copy and paste reference for me in the future.
I am going to assume you have the following installing:
- PHP (with "--with-fpm" option)
First we need to install Supervisord, to do this we need to install "pip". You can do this by running the following commands:
This will then allow you to run:
sudo pip install supervisor
We can now create our supervisord.conf file, which will tell Supervisor how and what to run. I created mine in
/usr/local/etc/supervisord.conf. Note that you can create it in a few different locations and Supervisord will automatically pick it up, have a look at their docs for this.
The following is my
supervisord.conf file, which includes configs to run the web interface:
port = 127.0.0.1:9001
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups = 5
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
user = root
directory = /tmp
strip_ansi = true
; RPC Interface
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
serverurl = http://127.0.0.1:9001
files = /usr/local/etc/supervisor.d/*.conf
If you notice on the last line, we are including files from
/usr/local/etc/supervisor.d. This means we can place config files for PHP, Nginx etc in this folder to keep it cleaner, however you can place all the configs in the above file if you so with.
First off, we will create the config file for php-fpm in
command = /usr/local/sbin/php-fpm --nodaemonize
user = root
autostart = true
The above will run php on startup as root.
Next we will add the Nginx config file in its respective file:
command = /usr/local/bin/nginx
user = root
autostart = true
This will also run nginx on startup as root. You will also want to add the following to your main nginx config file:
This will stop nginx from daemonizing it's self, and is needed for nginx to run smoothly.
Run the following command to tell Supervisor to look for config file changes. Please note that you will need to run this every time you make a change to the config files.
That should be it all setup ready for you to get these processes running. Simply type the following to test this out:
supervisorctl start php;
supervisorctl start nginx;
PHP and Nginx should now be running, to check this simply run. You should see "RUNNING":
supervisorctl status php
To get Supervisord to start when your Mac starts, you will want to use launchctl. Simply put the following inside
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
launchctl load /Library/LaunchDaemons/com.agendaless.supervisord.plist
At this stage, Supervisord should be running and ready to use, however I do normally have to restart my Mac for things to work properly. This could have been due to launchctl having not been used before this.
To check that it is running, simply go to in your browser, or use the following command:
If all works well, you should see the following in your browser:
If you have any questions, or suggestions please let me know in the comments below, or tweet me
Over the past few months I have been searching for a backup solution for my VPS's. I wanted a single solution that allowed me to backup multiple sources such as MongoDB, MySQL and the usual files.
After a while searching, I decided I would build it myself, due to not being able to find the perfect solution.
Before this, I simply had the Dropbox service running on each machine, and had a cron that copied mysqldump into the Dropbox folder, which was synced. This worked well, but it was quite laborious to setup.
Because of this, I opted to use the Dropbox API directly to backup from the tool. This allowed me to deploy the script to any server (see here) and the only dependencies are PHP and Curl.
When setting it up, all you need to do is run:
This will give you an authorisation link for Dropbox, which will return a token which is used to build your config file.
Once you have set the config file up (see the repo's README.md for details). You will be able to simply setup a cron to run the following for instance:
This will loop over each database you have access to, mysqldump them, gzip them and upload them to Dropbox. My MySQL (and MongoDB) backups, are set to backup once per hour, but the file is stored YMD, which means that the file will be overwritten. This would normally be a bad thing since you could overwrite with a bad backup easily, but because we are using Dropbox, it keeps internal revisions meaning that we have around 23 copied per day, but we keep the storage space to a minimum.
If you would like to view the source, and maybe use the tool, then please head over to Github. Let me know if you have any questions, or suggestions.