Skip to content

Instantly share code, notes, and snippets.

@JacobBennett
JacobBennett / blog.md
Last active October 21, 2023 17:30
Clean up your Vue modules with ES6 Arrow Functions

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({
@JacobBennett
JacobBennett / QueueRetryAllCommand.php
Created November 11, 2015 05:32
Laravel Queue:Retry-Multiple and Queue:Retry-All
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class RetryAllCommand extends Command
{
/**
* The name and signature of the console command.
@JacobBennett
JacobBennett / ReadMe.MD
Last active September 30, 2023 09:14
Loading Laravel Sentry only for production

Loading Laravel Sentry package only for production

In the case that you don't want development errors making their way to Sentry for error tracking, you can use the code below to ensure that Sentry will only record exceptions when in production.

First, instead of loading the SentryLaravelServiceProvider in the config/app.php providers array, we will load it in our App/Providers/AppServiceProvider.php. This allows us to check the environment before loading the appropriate service providers.

Seconly, in our App/Exceptions/Handler.php we again check for the production environment before trying to capture the exception using Sentry. This second step prevents Sentry from trying to catch an exception when it isn't bound in the container.

@JacobBennett
JacobBennett / blog.md
Last active June 4, 2023 05:50
Sharing Laravel Cookies across subdomains

I recently ran into a problem where I had a suite of applications hosted on a set of subdomains that all needed to be able to share a single cookie. Any cookies other than the shared cookie needed to stay specific to their subdomain, but this one shared cookie needed to be accessible to any of them. I also wanted to accomplish this using Laravel's Cookie facade.

The Problem

To accomplish this, there were two issues to solve.

  1. All cookies created by the Laravel framework are encrypted by default. (link)
  2. I needed to figure out how to set a domain on the shared cookie that was different than the domain it was being set from.

Setting Non-Encrypted Cookies

In Laravel 5.1, a feature was added which allows you to add a list of cookie names that should not be encrypted to the EncryptCookies Middleware under the $except array. Check out [the docs](http://laravel.com/docs/5.1/responses#attaching-cookies

@JacobBennett
JacobBennett / blog.md
Last active November 4, 2022 20:41
The Hows and Whys of Software Development (Writing a SDLC)
@JacobBennett
JacobBennett / blog.md
Last active August 30, 2022 15:25
Setting up a $5 Staging Server with Forge, Envoyer, and Nginx

Ever wanted to have your very own staging server? Here is how to make that happen for $5 bucks a month (assuming you are already using Forge and Envoyer).

1. Spin up a new server with Forge on Digital Ocean for $5 bucks.

For first time Forge users, I would highly suggest this great blog post from the one and only Matt StaufferUp and running with Forge

If you learn better through video, check out the free Forge series on Laracasts - Server Management With Forge

2. Set up Envoyer to auto-deploy from your staging branch

<?php
$var = 'testing';
?>

Hey there

undefined

<?php
$var = 'hello';