Link

The Rework Podcast – Jason Friend at Industry 2017

I know many of you know Basecamp but do any of you follow Jason Fried, CEO of Basecamp. Jason has become quite a controversial, outspoken person online. He has published some amazing ‘best seller’ books, and I recommend you all read ‘Getting Real’ (available as a free PDF)

Anyway, they have recently started to publish a new podcast called Rework. On my run this morning I listened to this one https://rework.fm/jason-fried-industry-2017 and there were some comments in it that really struck me as important so I thought I would share.

Enjoy.

Laravel Watchable Package

I created this package to ‘scratch my own itch’. I have a model called Order. I wanted to notify certain people (only people who were watching the order) when the status of the order changed.

In this article, I will give you some boilerplate code that you can use in your application to wrap around the Laravel Watchable package.  If you fancy reading a little more about why I needed to build it in the first place, read the “A little background into ‘Why'” at the end of the page.

The problem

In the documentation, under the Using The Notification Facade section, you can see the example below.

However, the question is, how do you get the users? What I want to be able to do is send a collection of users who are watching the model.

The solution

Install the Laravel Watchable Package (https://github.com/jamesmills/watchable)

Remember to add the trait to your model. Throughout this post, I will use Order as the example.

Once you have the package installed this will help you handle the watchable request on the model. However, you will still need to add some additional functionality to your application. Below is some scaffolding which I hope will help.

I have created a separate controller to deal with this so that I can reuse the same controller for any models I want to be ‘watchable’.

To use this controller remember to add the route!

Now you can use the example below in your view file when you are showing the model you want to be watchable.

Important: The key thing to remember is that we send a hidden field with the ‘key’ as the model name you want to watch/unwatch. This is what makes our controller code reusable.

Now that we have added the ability for someone to be able to watch your model we can simply get the watchers of the model when we perform an action on it.

The below is a simplified version of what we have in our application when an order gets paused.

Notes

I use the Laracasts Easy Flash Messages for the flash()->success(‘message’) messages you can see in the controller to display the watching status back to the user after they have clicked the button.

A little background into ‘Why’

At Clicksco we are experts in traffic acquisition and we use this skill to drive traffic to highly optimised landing pages to generate form fill leads for a number of partners focusing in the financial industry.

We partner with a company called Lead Byte for lead processing and delivery which we use in combination with a number of in-house systems to manage the entire lead lifecycle.

A few months ago I was working on a new lead ordering module which would allow us to create an order for leads and have the system manage it. A lead order is when a company comes to us and says they will buy X number of leads from us. They might require people looking for Y product and the value of their fund might have to be above Z.

Within Lead Byte we set all the delivery configurations so we can delivery the lead directly to the clients CRM. We also set up rules to make sure the correct partner gets the correct leads. The one thing we were missing was being able to create a lead order to fit various scenarios. (Example: Send 
20 leads daily until a total of 500 leads have been sent or until 22nd Oct 17).

Using a combination of Laravel, Pusher and Vue we implemented our solution in our main system (we call this the PMD). What was missing was a way for us to notify specific people when certain things happened to an order. For example, when the daily frequency was met and the order was paused. Or, when the total number of leads for the order was delivered so the order is closed. Using Laravel 5.5 Notifications it’s easy to send out these notifications using a selection of different channels but the tricky part comes when you need to decide who to send the notification to.

The is why the Laravel Watchable package was developed. I allow anyone who can log into the system to ‘watch’ an order. Once they are a watcher of a lead order they will automatically get all notifications of all order status changes. It’s easy to find the order, get all its watchers and then send a notification to everyone who is watching.

 

Link

Free Grammar Checker

I stumbled across Grammarly, I actually think it was a Facebook Ad of all things. I liked the idea of adding the Chrome browser extension because it would mean that I could use it for nearly everything that I do day to day.

So far my experience has been good and so I thought it would be worth a share!

Grammarly makes sure everything you type is easy to read, effective, and mistake-free. Try it today:

Source: Free Grammar Checker | Grammarly

Get remote laravel log file

By now you are deploying your web applications via some sort of magic like Codeship and have probably decided to turn FTP off on your servers. Either that or you are using Forge and the only way you can get at your production server is via SSH.

If you want to run migrations on your production server then you can SSH in or maybe have an Envoy command to do this. However, what happens if you need to review your production log files from your Laravel app but you cannot just FTP in and download them.

At first I thought about doing it via Envoy but I could not get my head around how to use the ‘scp’ command. I ended up setting an alias to do it from my local machine using

alias get-amazing-com-log=”scp username@server.com:/home/web/amazing.com/app/storage/logs/laravel.log ~/Projects/amazing_com/app/storage/logs/”

Then I thought, how about a quick Laravel Command to do something like

php artisan logs:get

To do this we are going to make use of the SSH Class in Laravel, specifically SFTP Downloads. For us to be able to use this class we need to set some remote configurations.

To get started we need to go to ‘/app/config/remote.php’ and add the settings for your remote server, in this example we will set them for our production server.

You will notice that the only thing we actually set in this file is the ‘root’ as everything else is extremely sensitive so we are going to set those configuration items using “dot” files.

Once we have the configuration setup then we are ready to setup our new Artisan Command.

And remember to register this command so you have access to it when running Artisan on the CLI.

And there you have it. Now you can run a simple Artisan command from your local machine or from within your Homestead VM and it will connect to production, pull down the log file and store it in ‘app/storage.logs/production.log’.

You’re welcome.

Clicksco PHP Flow

This is the general flow in the PHP family at Clicksco. As of June 2014.

As an international company the general business relies a lot on email, Basecamp and Skype however as a tech team we have an arsenal of different tools and services we use and I would like to share our processes with you.

Instant Messaging and Beyond

We used Campfire for a long time; however more recently have moved to HipChat. Everything, and I mean everything, is centered around HipChat. We have rooms for general discussion, Design, Frontend, internal frameworks, PHP, .NET, Laravel, Music, Infrastructure Management, Project Management and the most important rooms of them all, project rooms.

Like GitHub, we like to centre everything possible into project rooms and have Clickbot (our version of Hubot) running in all rooms. Although we do not rely on Clickbot as much as GitHub relies on Hubot, we do rely heavily on the ethos that if it is not in a project room then it is not happening! Most of the team have the HipChat app on their mobile so if they are away from their desk and you @mention them in a room they will get a notification. It is then up to them how and when they respond.

Source Control & Project Management

As a company we use BitBucket as our central remote repository solution; however in the PHP family we have our primary remote repository (origin) set to a Codebase repository. Codebase classes itself as “Professional code hosting, with a complete suite of project management tools built-in.” Every project we work on has a Codebase project and that project may have one or many repositories. The most used feature in Codebase is the ticketing system, which we use to assign features, enhancements and bugs to members of the family. We then set ticket priorities and can give them relevant tags. Each Codebase project is then linked to a HipChat project room so that we get notifications on commits, ticket creation and ticket updates.

Agile Software Development

We follow the basic principles of SCRUM and so our day starts with a standup outlining what we worked on yesterday, what we have planned for the coming day and highlighting anything that is blocking progress. The standups are quick and done via Google Hangouts (because HipChat does not yet support team video chat).

Communication

Throughout the day HipChat is always open and is our central communication tool throughout the entire tech team, not just the PHP team. With the recent launch of individual video calling in HipChat we frequently have one to one calls to discuss ideas, issues and problems. HipChat also allows us to share our desktop screen with the other caller. Although we do use HipChat for this, we also frequently use Screenhero which has the added feature of allowing live collaboration. It is sometimes much easier to just let the other person click and type. Usually a request for a video call or screen share will be done in a project room in HipChat so itis nice to have the new ‘/hero @jamesmills’ command for HipChat which will open a Screenhero session with the user specified.

Source Control Workflow

All the tech teams at Clicksco use Git and in the PHP family we follow GitHub Flow. We all work on branches which are synced remotely on each commit. Once we are happy with a new feature or a bug fix, we create a merge request in Codebase and set one of our fellow family members to be the person responsible for the merge. This brings us nicely onto one of the most important steps in a projects lifecycle: Code Reviews. Every line of code committed will get reviewed by at least two developers. Code reviews are a fundamental part of our process. A code review helps to bring our team together, widen knowledge, pull everyone to the same level, give a sense of ownership and achievement, catch bugs, discover new feature enhancements and possible refactor opportunities.

Deployment

Deployment is always an interesting subject and I still find it staggering that in 2014 people are using FTP to download/upload files manually. For the situations where we have to use FTP to deploy to server we have a DeployHQ account (by those nice people at Atech Media). Our main deployment tool at the moment is Codeship. Codeship is proving to be an amazing tool and I would recommend you to try out their service, they have a free plan.

Once something is merged into the master branch, Codeship takes over. Codeship will run tests on all branches. If the merge is made on the master branch and all the tests pass, then Codeship will then run custom deploy scripts. As we have a number of projects deploying to a number of servers we keep all our deployment scripts in source control.

Obviously, whichever tool is being used, everything is set to report back to the project room in HipChat. You can literally see the commit, merge, test status and deploy result just by sitting in the HipChat room.

Bug Tracking

Once a system is running live on production we make use a service called BugSnag which reports any errors and exceptions on a given environment. For example, if an exception is thrown, then BugSnag will pick this up, automatically create a ticket in Codebase and notify the project room in HipChat. A member of the team will jump on the ticket, update its status, create a branch, commit code, merge request the branch and code review will take place. The merge will get approved, deploy will kick in, ticket will automatically get updated with ticket reference in the commit message and every single step will get logged via notifications to the project room in HipChat.

Communication tools and keeping up-to-date

We also have rooms in HipChat to discuss things like Laravel. Having things like new Laravel.io podcasts and new lessions on Laracats all fed into a central location is all part of the ethos so we use Zapier to monitor RSS feeds and post notifications into the rooms when something new is released. We are working on getting Clickbot to help us with this.

Is this the only way?

No, not by any means. I wanted to write this blog post to share what we do in the PHP team at Clicksco, at the moment. One of the main reasons I added the month and year at the start of this post is because there is no way of knowing when it will be outdated, probably as soon as next month. We have got to this stage by having a great team who are always bring new tools and services to the table and are willing to try new things. The key thing is that there is a method, there are principles and a procedure. Everything and everyone is open to change, but if you do not have an established process in the first place, you have no process to improve.

We also have a site that documents our flow and our tools that is available to view at http://php.clicksco.com. Please let me know your thoughts in the blog comments.

Conclusion

So that is about it. A brief summary of what we use and how we use it. As I am sure you have established, there is one tool that is a hub to all our activities. Having HipChat, although anything like Campfire or Slack would work, as a central hub has proven fundamental to improving communications and efficiency in the PHP family at Clicksco.

Why the emphasis on a central notifications hub like HipChat? Anyone, at any time, from any location, can go into any project room and know exactly what is happening. You can scroll through the room history to quickly get up to date and you can see live updates from everyone and every tool we use all in one place.

Soon we will be able to use Clickbot to issue more commands from within HipChat, heck we might be able to just all work from within HipChat.

Clicksco are looking for awesome people, are you one of them?

Dubai-based Clicksco employs more than 200 people in nine offices and six countries. It has a turnover of some US$100 million and serves more than 11 million customers per month through its network of comparison shopping, B2B, ecommerce and travel websites.

The technical arm of Clicksco is based in Middlesbrough in the UK and we are looking for new people to fill the below opportunities:

  • Product / Project Management
  • Front End Development / Inc Word Press
  • .net c#
  • Design
  • iOS
  • Android
  • PHP

If you are interested then please contact us@thap.co.uk

JetSetMe, IFTTT & Personal site

live.jamesmills.co.uk has been an ongoing experiment for a while now. It needs a little bit of an update but if you read the about page you should get a good idea of how I have it setup.

I recently updated my personal site (just a quick tidy up really) and I noticed I display where I am based but I am not always actually in that location. Thinking back to a recent update by IFTTT in which they announced a partnership with JetSetMe I started to think of a way I could show this information without having to actually update this myself.

I setup the JetSetMe channel in IFTTT. The JetSetMe service is something O2 are experimenting with which allows you to do things when O2 spot that you have arrived in a new country.

When JetSetMe picks up a new country IFTTT get triggered. I have IFTTT store data in JSON format in a file in Dropbox (you can see the recipe here). I then have a CRON job running on my server which opens this file periodically and saves all the data to a database which live.jamesmills.co.uk uses. This is basically how all the data on live.jamesmills.co.uk is generated.

I then have a very simple API on live.jamesmills.co.uk which gives me access to this data which means on jamesmills.co.uk I can show where I am currently located.

 

 

Open a php project in PHPStorm using Alfred

I have been using PHPStorm for a while now and after the recent release of version 5 (seems to be much faster) I am sticking with it for the foreseeable future.

I have also been using Alfred for a long time too. I purchased the Powerpack to get access to some of the more advanced features and have never regretted the small expense.

Today I found out Syd Lawrence has built an awesome plugin called Alfred Dev Doctor which helps developers find the correct documentation whilst coding. It needed Alfred v2 and the Powerpack.

I did not know there was a version 2 avaliable so I immediently downloaded the new version. Unfortuntly I then found out that my licence key for the version 1 Powerpack did not work with version 2 so I had to upgrade my Powerpack licence. The upgrade was a small fee of £10, worth it in my eyes. Since 14 May 2012, I have used Alfredapp 6,591 times, which is an average 20.9 times per day.

Since I had the all new singing and dancing version of Alfred and the Powerpack I began looking at other things I could get him to help me with. For months I have been trying to get Alfred v1 to open a folder with PHPStorm. I was never able to get this working. Luckily in Alfred v2 this was easy.

I have created a Workflow in Alfred which allows me to hit ‘alt+space’ then type ‘phps’ and then type a folder name to find it. Once it has found it I simply hit enter and it will open that folder up in PHPStorm. Yay!

A video of this working can be found here: Video showing Alfred opening a folder in PHPStorm

You can download the Workflow here, unzip and double click to install: PHPStorm Alfred Workflow