Laravel Archives | Lee Willis https://www.leewillis.co.uk/tag/laravel/ Fri, 25 Apr 2025 13:29:10 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.4 Using oEmbed resources in Laravel https://www.leewillis.co.uk/using-oembed-resources-laravel/ https://www.leewillis.co.uk/using-oembed-resources-laravel/#respond Fri, 16 Feb 2018 09:01:08 +0000 https://www.leewillis.co.uk/?p=1000 On a recent project we had a requirement to let users easily include social media such as YouTube videos, and Instagram posts in their content. We choose to follow the WordPress-embed style functionality where simply including a link to the … Continue reading

The post Using oEmbed resources in Laravel appeared first on Lee Willis.

]]>
On a recent project we had a requirement to let users easily include social media such as YouTube videos, and Instagram posts in their content. We choose to follow the WordPress-embed style functionality where simply including a link to the social media in the post would embed it using oEmbed discovery.

oEmbed allows a service (such as YouTube, or Instagram) to be queried in a standard way, and to return markup representing the resource. Embedding a YouTube video this way does what you’d expect – an embed of the video. Embedding Instagram embeds the image in an Instagram frame.

Before…

 

After…

In WordPress, all of this happens without the content author having to do anything complex – just paste in the URL of the content they want to embed into their post, and WordPress does the rest. We wanted to reproduce those features, and ease of use in our project, which isn’t WordPress, but based on the Laravel framework.

There are however plenty of libraries that you can use to do the heavy lifting – particularly embed/embed:

This lets you simply pass in a URL and get back all sorts of information, including the title, image, and embed code so you can use it how you like. This allowed us to get a proof of concept up and running in our project pretty quickly. However – everything was being embedded in realtime, with oEmbed calls being made to embed resources every time we loaded a page.

To solve this, we created a bridge between Laravel’s cache system and the embed library such that we can load an embed once, and cache the embed code produced, and just re-use that, decreasing load on external services, and increasing load times.

Usage, is simple you just use it as you would embed/embed. If the data is in the cache it will come from there, otherwise it will be fetched and cached automatically.

Happy embedding!

 

 

 

 

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Using oEmbed resources in Laravel appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/using-oembed-resources-laravel/feed/ 0
Custom model events with Laravel 5.4 https://www.leewillis.co.uk/custom-model-events-laravel/ https://www.leewillis.co.uk/custom-model-events-laravel/#comments Tue, 07 Mar 2017 13:46:42 +0000 https://www.leewillis.co.uk/?p=936 Laravel’s eloquent ORM has a nice system for tracking, and responding to events on models. This allows you to create an Observer class that handles code that should run when various actions are performed on a model. There are a … Continue reading

The post Custom model events with Laravel 5.4 appeared first on Lee Willis.

]]>
Laravel’s eloquent ORM has a nice system for tracking, and responding to events on models. This allows you to create an Observer class that handles code that should run when various actions are performed on a model. There are a set of standard events (created, updated, deleted etc.) that can be used to achieve many things. These can be useful if you need to send notifications when a new model is created, or update something when a model is updated.

However, as your models get more complex, you may find yourself needing different events. Imagine you have a content model which has statuses, for example draft, pending review, and published. If you want to perform different actions based on the model status then you can attach an observer to the model, and listed for the created / updated events.

You can then check the new status and fire off the relevant code. This can get messy though, and also doesn’t reflect what happened to the model to move it into it’s current status. For example, is the content in “pending review” because it’s a draft that someone wants to publish, or an article that was published but has been bumped back down for review? The current model status doesn’t tell you that.

Now, you can create your own events in Laravel, and fire them off, however that would mean you have some event listeners in your model observer, and some in a bespoke event listener. Messy.

It’s nicer to be able to handle everything the same way. Fortunately Eloquent’s model event system can be extended to support custom events which you can fire at the appropriate point.

To add a new event, simply set the $observables property on your model.

<?php

use Illuminate\Database\Eloquent\Model;

class MyContentModel extends Model
{
  /**
   * Additional observable events.
   */
  protected $observables = [
    'sentforreview',
    'rejected',
  ];
}

This tells Laravel that there are two new model events that an observer can listen for. In our observer, we can listed to these by defining the appropriate function as we would with any of the standard events:

<?php

namespace App\Observers;

class MyContentObserver
{

  public function sentforreview(MyContent $myContent)
  {
    // Your logic here.
  }

  public function rejected(MyContent $myContent)
  {
    // Your logic here.
  }

}

So far, so good. We have defined our custom observables, and built a method to listed for them. However – the event will never be fired. After all, Laravel doesn’t know when it should be fired. Firing the event is simple though. Within your model you simply call fireModelEvent() and tell it the event you are firing, for example:

<?php

use Illuminate\Database\Eloquent\Model;

class MyContentModel extends Model
{
  public function sendForReview()
  {
     // Do any other updates to the model here.
     // Then fire the event.
     $this->fireModelEvent('sentforreview', false);
  }

  public function reject()
  {
     // Do any other updates to the model here.
     // Then fire the event.
     $this->fireModelEvent('rejected', false);
  }
}

Now, you can have a single model observer that handles standard, and custom events keeping everything nice and tidy.

The post Custom model events with Laravel 5.4 appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/custom-model-events-laravel/feed/ 4
Testing Laravel emails with MailThief https://www.leewillis.co.uk/testing-laravel-emails-mailthief/ https://www.leewillis.co.uk/testing-laravel-emails-mailthief/#respond Fri, 28 Oct 2016 10:15:15 +0000 http://www.leewillis.co.uk/?p=807 The last couple of Laravel projects I’ve worked on have all included important emails being delivered. It was important that the triggering of these emails could be tested. I also needed to make sure that the correct email was being sent, … Continue reading

The post Testing Laravel emails with MailThief appeared first on Lee Willis.

]]>
The last couple of Laravel projects I’ve worked on have all included important emails being delivered. It was important that the triggering of these emails could be tested. I also needed to make sure that the correct email was being sent, as some processes would trigger different emails based on the data input.

In the first project, I relied on Mockery to test that Mail functions were called, e.g.

Mail::shouldReceive('send')
  ->once()
  ->with(
    'emails.enquiry',
    Mockery::any(),
    Mockery::any()
  );

This allowed testing that the correct email was being triggered. However if you want to test in more detail that that, for example testing that data from input has been inserted correctly into the email content then it gets a lot less straightforward. On the next project I tried to evolve how I was testing emails. I needed to do some more detailed testing on email contents, so I turned to the MailThief package.

This allowed me to easily test not only that emails were being triggered, but specific tests against the email content. Here’s some examples from my tests:

$this->seeMessageFor($company->email);
 $message = $this->lastMessage();
 $this->assertTrue(
  $message->contains('Web enquiry</title>'),
  $message->getBody('html')
 );
 $this->assertTrue(
  $message->contains('0100 000000'),
  $message->getBody('html')
 );
 $this->assertTrue(
  $message->contains('<a href="tel:0100000000'),
  $message->getBody('html')
 );

I find it much more consistent to keep assertions after the actions in my test rather than having them as expectations before my actions. The package has proved so flexible that I’ll be using it for all email-related tests in future.

Thanks Tighten Co!

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Testing Laravel emails with MailThief appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/testing-laravel-emails-mailthief/feed/ 0
Image handling in PHP with Intervention Image https://www.leewillis.co.uk/image-handling-php-intervention-image/ https://www.leewillis.co.uk/image-handling-php-intervention-image/#respond Thu, 27 Oct 2016 11:00:42 +0000 http://www.leewillis.co.uk/?p=793 If you’ve done much with PHP you’ve probably come across its image handling libraries. Normally this involves using either the GD, or ImageMagick. These work reasonably well, but there are a number of disadvantages: The APIs are thin wrappers around the … Continue reading

The post Image handling in PHP with Intervention Image appeared first on Lee Willis.

]]>
If you’ve done much with PHP you’ve probably come across its image handling libraries. Normally this involves using either the GD, or ImageMagick.

These work reasonably well, but there are a number of disadvantages:

  1. The APIs are thin wrappers around the relevant image libraries. Neither of them offer particularly developer-friendly APIs, and the two APIs aren’t equal enough to make switching between them simple.
  2. You have to know which library your server has in order to start developing, or make extra work, and support both.

On a recent project I needed to do image manipulation (thumbnail generation etc.), and came across the Intervention Image library. This is a PHP library that can be used in any PHP project, and offers a much improved API for working with images. The API is agnostic to whether you’re using ImageMagick, or GD, so you can swap between them at will without having to re-code your application.

Next time you’re working with images, check out Intervention Image.

 

 

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Image handling in PHP with Intervention Image appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/image-handling-php-intervention-image/feed/ 0
Activity logging in Laravel https://www.leewillis.co.uk/activity-logging-laravel/ https://www.leewillis.co.uk/activity-logging-laravel/#respond Wed, 26 Oct 2016 09:54:00 +0000 http://www.leewillis.co.uk/?p=803 I’ve been working on a new service for the last month or so that enables people to log, track and share walks in the UK’s hills and mountains. The service is based on Laravel, and one of the things I … Continue reading

The post Activity logging in Laravel appeared first on Lee Willis.

]]>
I’ve been working on a new service for the last month or so that enables people to log, track and share walks in the UK’s hills and mountains. The service is based on Laravel, and one of the things I wanted to include on the site was an “activity feed”.

There are two types of feed I wanted to create. The first was for my own benefit. I wanted to see a simple timeline of activity on the site as usage builds up. Secondly, I wanted to be able to log data so that I can create public timelines in the future.

This is all pretty simple to build from scratch, but it turns out that the team at Spatie have already got this covered with a general package for logging activity on a Laravel application.

You can easily log custom activity events wherever you like, it’s as easy as:

activity()->log('My custom message here');

Even better though is that you can get it to log changes to Eloquent models automatically using the handy LogsActivity trait. If you add the trait to your model, then creating, updating or deleting a model will automatically create a log entry. The log entries include the item affected, and the “causer” (normally a user).

Going beyond the basics, you can also define custom messages, choose what data to store along with log events.

The activities are logged as normal Eloquent models, so once you have your data logged it’s easy to pull out the information you need using standard Laravel querying, and views.

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Activity logging in Laravel appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/activity-logging-laravel/feed/ 0
Adding Google Maps to your Laravel application https://www.leewillis.co.uk/google-maps-laravel-application/ https://www.leewillis.co.uk/google-maps-laravel-application/#respond Tue, 25 Oct 2016 15:23:57 +0000 http://www.leewillis.co.uk/?p=789 On a recent project, I needed to add some Google Maps functionality to a number of pages. The functionality I was looking for included: adding KML layers adding markers onto the maps with custom info windows layering photo thumbnails onto … Continue reading

The post Adding Google Maps to your Laravel application appeared first on Lee Willis.

]]>
On a recent project, I needed to add some Google Maps functionality to a number of pages. The functionality I was looking for included:

  • adding KML layers
  • adding markers onto the maps with custom info windows
  • layering photo thumbnails onto the maps.

While I’ve used the Google Maps JavaScript API plenty of times before, I was looking to minimise the amount of custom code I used. The project is Laravel-based, so I had a look around for an existing package to handle some of the basic features. I ended up picking the Googlmapper package by Brad Cornford:

With the library in place, I didn’t have to worry about the basics. Instead, I spent my time on custom elements I wanted to add. I logged an issue early on with a bug that came up with my use case, and Brad was really helpful getting it resolved and into a release. Brad is actively working on the library, and a few features I was planning as custom ended up being covered by updates to the library mid-project.

Each time I moved on to another feature I found something in the library to help me. If you’ve got developers who are comfortable with Laravel and PHP, but not necessarily JavaScript, it’s a really nice library that lets you build your solution in PHP. 

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Adding Google Maps to your Laravel application appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/google-maps-laravel-application/feed/ 0
Backing up your Laravel app https://www.leewillis.co.uk/backing-laravel-app/ https://www.leewillis.co.uk/backing-laravel-app/#respond Thu, 20 Oct 2016 09:00:34 +0000 http://www.leewillis.co.uk/?p=801 With a couple of Laravel developments out in the wild, I needed to make sure that they were integrated with my existing backup solution, which includes archived / off-server storage of backups. Pulling down the backups once I had them … Continue reading

The post Backing up your Laravel app appeared first on Lee Willis.

]]>
With a couple of Laravel developments out in the wild, I needed to make sure that they were integrated with my existing backup solution, which includes archived / off-server storage of backups. Pulling down the backups once I had them is pretty straightforward – everything is already set up to do that from the servers I use.

For WordPress sites, I usually use the BackUpWordPress plugin from the team at Human Made:

BackUpWordPress
by Tom Willmot

BackupWordPress was created by our friends at Human Made but is now under new ownership. We’re committed to opensource and WordPress and will provide free support for the many BackupWordPress fans.
We’ll make occasional updates to the free software – please send us any patches you’d like to see released here: https://github.com/orgs/xibodevelopment/

However, we’ll no longer be selling or supporting the paid add-ons (e.g. for backups to Dropbox and Google Drive). It’s certainly a good idea to backup to cloud storage to protect against server-wide risks.
For this we recommend UpdraftPlus WordPress Backups which can do things for free BackupWordPress Premium could do on a paid basis. Click here for full comparison.

BackUpWordPress will back up your entire site including your database and all your files on a schedule that suits you. Try it now to see how easy it is!

This plugin requires PHP version 5.3.2 or later

Features

  • Super simple to use, no setup required.
  • Works in low memory, “shared host” environments.
  • Manage multiple schedules.
  • Option to have each backup file emailed to you.
  • Uses zip and mysqldump for faster backups if they are available.
  • Works on Linux & Windows Server.
  • Exclude files and folders from your backups.
  • Good support should you need help.
  • Translations for Spanish, German, Chinese, Romanian, Russian, Serbian, Lithuanian, Italian, Czech, Dutch, French, Basque.

Translations

We’d also love help translating the plugin into more languages, if you can help then please visit https://translate.wordpress.org/projects/wp-plugins/backupwordpress/dev/ to start translating.

Stats:

  • Current version: 3.14
  • Rating: 94(1373 ratings)
  • Downloaded 4,916,838 times

For Laravel though, I was starting afresh. I found what looked like a good solution in the form of the Laravel Backup package from the team at Spatie. There were a couple of things I liked about the package:

  • It’s simple, straightforward, and does one thing (create backups) well.
  • It’s from a team who have a clear track record of delivering open source packages
  • From a look through the issue queue, it’s well maintained and open to pull requests from users.

A package to backup your Laravel app
https://github.com/spatie/laravel-backup
786 forks.
6,023 stars.
1 open issues.

Recent commits:

While I’m using it to back up to the local filesystem initially (backups are then transferred offsite separately by an existing system), the package allows you to put your backups onto any supported filesystem, so having it backup to S3, Dropbox, FTP, Rackspace cloud files or similar is just as straightforward.

I love the team’s concept of “Postcardware“, it’s nice as an open source author to know that your work is being appreciated, and used, and I hope they get plenty of postcards!

I have to say though, the real highlight in finding this package was finding Spatie and their broad range of Laravel packages – there’s at least one more that features in this series, and I can easily see myself using more of their packages in the future – thanks Spatie!

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Backing up your Laravel app appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/backing-laravel-app/feed/ 0
WYSIWYG with Summernote https://www.leewillis.co.uk/wysiwyg-with-summernote/ https://www.leewillis.co.uk/wysiwyg-with-summernote/#comments Wed, 19 Oct 2016 09:00:11 +0000 http://www.leewillis.co.uk/?p=809 Yesterday’s post talked about the concept of finding things missing, or needing implementing when moving from CMS-as-a-base to pure development frameworks. Yesterday it was enforcing password complexity. Today’s post is about the very core of a CMS – WYSIWYG content editing. There … Continue reading

The post WYSIWYG with Summernote appeared first on Lee Willis.

]]>
Yesterday’s post talked about the concept of finding things missing, or needing implementing when moving from CMS-as-a-base to pure development frameworks.

Yesterday it was enforcing password complexity. Today’s post is about the very core of a CMS – WYSIWYG content editing.

There are plenty of different options for WYSIWYG editors. I took the opportunity to scout around to see what was available, and finally settled on Summernote.

screenshot-2016-10-18-17-45-04

It’s simple, easy to configure to choose which elements you want to make available, you can just attach it to your textarea to have the markup submitted by your form, e.g.

<textarea class="summernote" rows="8" name="description" cols="50">
</textarea>
$('.summernote').summernote({
 height: 300,
 toolbar: [
   ['style', ['style', 'bold', 'italic', 'underline', 'clear']],
   ['font', ['strikethrough', 'superscript', 'subscript']],
   ['para', ['ul', 'ol', 'paragraph']],
 ],
 styleTags: ['p', 'blockquote', 'h2','h3'],
});

Next time you need a WYSIWYG editor – give Summernote a try.

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post WYSIWYG with Summernote appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/wysiwyg-with-summernote/feed/ 1
Enforce user password strength https://www.leewillis.co.uk/enforce-user-password-strength/ https://www.leewillis.co.uk/enforce-user-password-strength/#respond Tue, 18 Oct 2016 09:00:21 +0000 http://www.leewillis.co.uk/?p=797 I’ve worked with Drupal & WordPress for the majority of my projects for many years. For a lot of projects that are content-centric they can make a good starting point, and minimize the amount of custom work that needs to … Continue reading

The post Enforce user password strength appeared first on Lee Willis.

]]>
I’ve worked with Drupal & WordPress for the majority of my projects for many years. For a lot of projects that are content-centric they can make a good starting point, and minimize the amount of custom work that needs to be done.

Starting with WordPress or Drupal gives you a user framework, permissions, content management, easy content display, and a wealth of prebuilt modules / plugins to get your project off to a quick start.

However, they do have their limitations, and they’re not for every project. More recently I’ve been working with Laravel as a development framework on a number of projects that made sense to build from the ground-up. Established Laravel agencies / developers probably already have a set of add-ons that they regularly use to build out common features, but for someone relatively new to the framework, a lot of my time has been spent finding the building blocks to fill in missing bits of the puzzle.

I’m going to cover a number of these in future articles (backups / WYSIWYG editing / content filtering) in future articles of the series, but today I’m going to talk about user registration.

Laravel has scaffolding built out for user management, including registration, and password management. However – the default setup doesn’t do anything to enforce password rules / guidelines on users. One of my recent projects includes users registering for a service, and I wanted to make sure that they weren’t using too simple passwords. WordPress does this out of the box, and Drupal has plenty of modules to choose from, but for Laravel I had to look for something to plug in.

The library I settled on was zxcvbn-php :

This is a PHP implementation of the Javascript zxcvbn project from Dropbox and @lowe, and works really nicely. It’s a general purpose library – so can be used with any PHP project. Just give it an entered password, and it will evaluate it for you, allowing you to choose what level of passwords you want to accept. Read the Dropbox link, or this Xkcd cartoon for background on the sort of things it checks for.

Wiring it up to Laravel was a small job (If there’s any interest I can write that up separately), essentially just extending Laravel’s validation framework, and setting the validation control on the RegisterController.

Image credit: https://xkcd.com/936/

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Enforce user password strength appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/enforce-user-password-strength/feed/ 0
Error tracking with Sentry https://www.leewillis.co.uk/error-tracking-sentry/ https://www.leewillis.co.uk/error-tracking-sentry/#respond Thu, 13 Oct 2016 09:00:42 +0000 http://www.leewillis.co.uk/?p=795 One of the projects I’ve worked on recently is a rebuild of workflow system for a large business. The system processes large volumes of data 24 hours a day. It’s important that any errors with the system are flagged, tracked and … Continue reading

The post Error tracking with Sentry appeared first on Lee Willis.

]]>
One of the projects I’ve worked on recently is a rebuild of workflow system for a large business. The system processes large volumes of data 24 hours a day. It’s important that any errors with the system are flagged, tracked and investigated as soon as possible.

Another of the projects is a personal project I’m launching for Hill Blogging. This service is now in beta release with a handful of beta testers. I’m keen to identify, and squash any bugs without relying on beta testers reporting them.

Both of these projects use the Laravel PHP Framework (although neither Sentry.io, nor this post are Laravel specific!). So, I set about looking for a solution that would automatically track, and alert me to errors with Laravel. Any solution had to give me enough information to identify and start fixing the error.

On both of these projects I settled on Sentry.io. It’s a SaaS product that describes itself as:

Real-time error tracking [that] gives you insight into production deployments and information to reproduce and fix crashes.

This is pretty much everything I was looking for.

screenshot-2016-10-12-19-46-04

Sentry offers a Laravel integration out of the box. Simply install it, attach it to your project, and set up your project key. It’s a really straightforward setup. Once it’s set up, then any exceptions thrown in your code will get logged to Sentry, together with a backtrace. You’ll also be alerted to the new error.

You can take things further if you want by logging additional information with the exceptions if you need to, but the basic setup is sufficient to get you going.

Beyond Laravel, Sentry has libraries for common frameworks, and client libraries for most mainstream libraries, so it should be relatively easy to get going with.

There’s a range of pricing options depending on your likely error volume (zero – right!?) and users. The free tier is a great way to get started and offers support for 5,000 events/day (~150,000/month) at time of writing.

For me, it’s already more than proved its worth, not only in production, but also during development / staging phases of projects, helping me get straight to the broken code without having to rely on vague bug reports from users.

It’s worth noting that there are other similar services. In my investigations, I also looked at Rollbar and Airbrake – they may work better for you depending on your own circumstances.

  1. Stuff I’ve used
  2. Error tracking with Sentry
  3. Autotrack for Google Analytics
  4. WordPress performance tracking with Time-stack
  5. Enforce user password strength
  6. WYSIWYG with Summernote
  7. Backing up your Laravel app
  8. Adding Google Maps to your Laravel application
  9. Activity logging in Laravel
  10. Image handling in PHP with Intervention Image
  11. Testing Laravel emails with MailThief
  12. Assessing software health
  13. IP Geolocation with MaxMind’s GeoLite2
  14. Uptime monitoring with Uptime Robot
  15. Product tours with Hopscotch
  16. Background processing for WordPress
  17. Using oEmbed resources in Laravel

The post Error tracking with Sentry appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/error-tracking-sentry/feed/ 0