Mitchell McKenna - tagged with laravel http://mitchmckenna.com/feed en-us http://blogs.law.harvard.edu/tech/rss LifePress mitchellmckenna@gmail.com Hiring Taylor Otwell to build HelpSpot & Laravel at the same time | Ian Landsman, HelpSpot Founder http://mitchmckenna.com/post/19400/hiring-taylor-otwell-to-build-helpspot-laravel-at-the-same-time-ian-landsman-helpspot-founder

Been looking forward to this podcast, Laravel in relation to real businesses out there.

In our very first episode, Matt had the pleasure of speaking with Ian Landsman, affectionately known as the 'Godfather of Laravel,' where they discussed his long history with Laravel and his business journey. Ian shared insights into his primary venture, UserScape, and its flagship product, HelpSpot, a help desk application he started 20 years ago. They also talked about taking a bet on Taylor and Laravel early on, bootstrapped startups, and more

]]>
Wed, 29 May 2024 07:46:00 -0400 http://mitchmckenna.com/post/19400/hiring-taylor-otwell-to-build-helpspot-laravel-at-the-same-time-ian-landsman-helpspot-founder/hiring-taylor-otwell-to-build-helpspot-laravel-at-the-same-time-ian-landsman-helpspot-founder
Building a jsonapi in Laravel? I created an example API with features & packages I've found really http://mitchmckenna.com/post/17827/mitchellmckenna-building-a-jsonapi-in-laravel-i-created-an-example-api-with-features-packages-ive-found-really-useful-httpstco22ysap7tvu-php

Building a #jsonapi in #Laravel? I created an example API with features & packages I've found really useful! https://t.co/22ysAP7tvU #php

]]>
Tue, 05 Sep 2017 13:02:00 -0400 http://mitchmckenna.com/post/17827/mitchellmckenna-building-a-jsonapi-in-laravel-i-created-an-example-api-with-features-packages-ive-found-really-useful-httpstco22ysap7tvu-php/mitchellmckenna-building-a-jsonapi-in-laravel-i-created-an-example-api-with-features-packages-ive-found-really-useful-httpstco22ysap7tvu-php
/u/mitchmckenna on Reducing Validation Bloat http://mitchmckenna.com/post/17752/umitchmckenna-on-reducing-validation-bloat

No problem with form requests, I like form requests, I'm just providing an alternative approach, especially for Lumen users who don't have form requests. If it's a simple API I find the config approach works really well, if I have to override the authorize() function or need to add an After Hook I use form requests for that app.

]]>
Sat, 05 Aug 2017 13:07:00 -0400 http://mitchmckenna.com/post/17752/umitchmckenna-on-reducing-validation-bloat/umitchmckenna-on-reducing-validation-bloat
/u/mitchmckenna on Reducing Validation Bloat http://mitchmckenna.com/post/17748/umitchmckenna-on-reducing-validation-bloat

If the single config file gets too unwieldy, you could turn it into a folder /config/validation/ and then have a file for each object type post/author etc.

]]>
Fri, 04 Aug 2017 14:35:00 -0400 http://mitchmckenna.com/post/17748/umitchmckenna-on-reducing-validation-bloat/umitchmckenna-on-reducing-validation-bloat
Reduce Validation Bloat in Laravel Controllers http://mitchmckenna.com/post/17745/mitchellmckenna-reduce-validation-bloat-in-laravel-controllers-httpstcoj2kxikja5o-laravel-protip

Reduce Validation Bloat in Laravel Controllers https://t.co/J2KXIkjA5o #laravel #protip

]]>
Fri, 04 Aug 2017 12:17:00 -0400 http://mitchmckenna.com/post/17745/mitchellmckenna-reduce-validation-bloat-in-laravel-controllers-httpstcoj2kxikja5o-laravel-protip/mitchellmckenna-reduce-validation-bloat-in-laravel-controllers-httpstcoj2kxikja5o-laravel-protip
jwt-auth: Deleted Users Causing Errors http://mitchmckenna.com/post/17328/jwt-auth-deleted-users-causing-errors

Recently ran into a situation using jwt-auth for Laravel where deleted users were causing errors because after deleting the user the auth token was still valid in redis, whoever the user no longer existed in the database, so when there was any calls to $auth->user() or Auth::user() it would error out when trying to make calls against that user object because false is returned.

When a user was deleted we should call $jwtAuth->invalidate($token) for that user but that's not gonna help us now that we have a bunch of other users who were deleted or if you need to delete users from DB manually.

I didn't want to have to check that calls to the Auth guard would not return false all over the place where I used the auth guard, so I looked for another answer.

Solution

Well it turns out others must have come across this issue as well because a merged PR to the project added a function to JWTGuard to throw a UserNotDefinedException if the user is not found. They didn't replace what happens when the user() function is called in order to stay compatible with how laravel's default guard returns false if not found. So use userOrFail() any place you normally would have used user.

]]>
Mon, 30 Jan 2017 17:53:25 -0500 http://mitchmckenna.com/post/17328/jwt-auth-deleted-users-causing-errors/jwt-auth-deleted-users-causing-errors
Failed to restart php7.0-fpm.service: Unit php7.0-fpm.service not found. http://mitchmckenna.com/post/17307/failed-to-restart-php70-fpmservice-unit-php70-fpmservice-not-found

You might have this happen to you if you switch back to an old project using Homestead. Basically you have a new version of the laravel/homestead vagrant box (1.0.1) which includes php 7.1 but the package in composer ^3.0 is expecting php 7.0.

Solution

Just add the line version: 0.6.0 to your homestead.yaml to indicate you want that version for the vagrant box which is the last one that includes php 7.0.

]]>
Tue, 24 Jan 2017 17:36:46 -0500 http://mitchmckenna.com/post/17307/failed-to-restart-php70-fpmservice-unit-php70-fpmservice-not-found/failed-to-restart-php70-fpmservice-unit-php70-fpmservice-not-found
Laravel Angular Admin: Laravel + Angularjs + Bootstrap + AdminLTE http://mitchmckenna.com/post/16945/laravel-angular-admin-laravel-angularjs-bootstrap-adminlte

Binded by Gulp workflow Admin Dashboard Boilerplate. Plus Oauth and JWT authentication on the side.

]]>
Fri, 03 Jun 2016 18:34:00 -0400 http://mitchmckenna.com/post/16945/laravel-angular-admin-laravel-angularjs-bootstrap-adminlte/laravel-angular-admin-laravel-angularjs-bootstrap-adminlte
Laravel Queued Jobs + Doctrine - Fix Objects Not Updating Between Jobs Run http://mitchmckenna.com/post/15632/laravel-queued-jobs-doctrine-fix-objects-not-updating-between-jobs-run

The issue is that doctrine is keeping the objects in local memory because the daemon is basically a php long-running process. In order to allow the objects used by the job to get updated, you need to $em->detach() the objects. But you'd also have to have cacade={"detach"} on all relationships that object has as well. So the best thing is to just call $em->clear() at the end of your job. This will detach all objects from doctrine and it will get a fresh copy of all the objects from the database for the next job run.

]]>
Wed, 10 Feb 2016 07:34:54 -0500 http://mitchmckenna.com/post/15632/laravel-queued-jobs-doctrine-fix-objects-not-updating-between-jobs-run/laravel-queued-jobs-doctrine-fix-objects-not-updating-between-jobs-run
Adonis - Nodejs MVC Framework Inspired by Laravel http://mitchmckenna.com/post/16139/adonis-nodejs-mvc-framework-inspired-by-laravel

This new NodeJS framework was inspired by Laravel, with similar folder structure and includes IOC container, very similar router, service providers, middlewares, even Views similar to blade. Utilizes ES6 classes for controllers. Even has an ORM called Lucid.

]]>
Wed, 20 Jan 2016 19:08:00 -0500 http://mitchmckenna.com/post/16139/adonis-nodejs-mvc-framework-inspired-by-laravel/adonis-nodejs-mvc-framework-inspired-by-laravel
Laravel Queued Jobs + Doctrine - Fix Mysql Has Gone Away Errors http://mitchmckenna.com/post/15630/laravel-queued-jobs-doctrine-fix-mysql-has-gone-away-errors

With long running processes you can get a 2006 MySQL server has gone away error. This adds a class that calls Doctrine's DBAL Connection's $conn->ping() to see if it's gone away, if so close the connection and let DBAL automatically open a new connection on the next query attempt. This is talked about in the Doctrine's Github repo here. Here's some pseudo code on how to do it:

<?php

namespace Acme\Doctrine\ORM;

use Doctrine\ORM\EntityManager;

class ConnectionSaver
{
    /**
     * Ping the DB server, if connection is lost close it and DBAL will
     * automatically reconnect on the next DB call.
     */
    public function checkDatabaseConnection()
    {
        /** @var \Doctrine\DBAL\Connection */
        $conn = app(EntityManager::class)->getConnection();

        try {
            $ping = $conn->ping();
        } catch (\ErrorException $e) {
            $conn->close();
        }
    }
}

Then inside the command handler you just inject the class and call checkDatabaseConnection() function.

<?php

namespace App\Listeners\Commands;

use Acme\Doctrine\ORM\ConnectionSaver;

class FooHandler
{
    public function __construct(ConnectionSaver $connectionSaver) {
        $connectionSaver->checkDatabaseConnection();
    }
]]>
Wed, 20 Jan 2016 03:34:54 -0500 http://mitchmckenna.com/post/15630/laravel-queued-jobs-doctrine-fix-mysql-has-gone-away-errors/laravel-queued-jobs-doctrine-fix-mysql-has-gone-away-errors
Laravel Doctrine - A drop-in Doctrine2 implementation for Laravel 5 http://mitchmckenna.com/post/15757/laravel-doctrine-a-drop-in-doctrine2-implementation-for-laravel-5

Several php packages to easily integrate Doctrine 2 into your next Laravel/Lumen project. The 'orm' package includes a ServiceProvider to add Doctrine to your project and configure it. The 'extensions' package includes several extensions including timestampable, softdeletable, etc. The 'migrations' package add ability to use Doctrine's migration package instead of laravel's migrations so that you can easily take advantage of auto migration generation based on entities. The 'ACL' package includes traits to add roles and permissions to user objects to easily integrate with Laravel's new ACL.

]]>
Mon, 14 Sep 2015 14:22:00 -0400 http://mitchmckenna.com/post/15757/laravel-doctrine-a-drop-in-doctrine2-implementation-for-laravel-5/laravel-doctrine-a-drop-in-doctrine2-implementation-for-laravel-5
Adding Roles and Permissions to Laravel's ACL [Laracasts] http://mitchmckenna.com/post/15754/adding-roles-and-permissions-to-laravels-acl-laracasts

This video tutorial goes over [one way] you can add the ability to give user's roles and specify which permissions those roles have. You would have to build upon this further to include additional features such as role inheritance or user-specific permissions (overrides).

]]>
Sun, 13 Sep 2015 19:26:00 -0400 http://mitchmckenna.com/post/15754/adding-roles-and-permissions-to-laravels-acl-laracasts/adding-roles-and-permissions-to-laravels-acl-laracasts
Things Laravel Made Me Believe - Jeffrey Way - Laracon EU 2015 http://mitchmckenna.com/post/15704/things-laravel-made-me-believe-jeffrey-way-laracon-eu-2015

Occam's razor, holds true even in programming.

Laravel's extreme success and popularity can be reduced to a single word: simplicity. Surprisingly, however, writing simple code is no easy feat! This talk will discuss key decisions that led to Laravel's success, while, in the process, reviewing a number of lessons-learned from over-architecting applications.

]]>
Tue, 01 Sep 2015 10:08:00 -0400 http://mitchmckenna.com/post/15704/things-laravel-made-me-believe-jeffrey-way-laracon-eu-2015/things-laravel-made-me-believe-jeffrey-way-laracon-eu-2015
Laravel-ResponseCache http://mitchmckenna.com/post/15636/laravel-responsecache

Speed up your website by caching entire responses. By default it will cache all successful GET requests for a week. Can store cache in any Laravel supported cache (file, redis, memcache). You can have separate caches per user. If you want more granular caching like ESI includes or reverse proxy caching check out laravel-httpcache.

]]>
Tue, 21 Jul 2015 16:24:00 -0400 http://mitchmckenna.com/post/15636/laravel-responsecache/laravel-responsecache
Laravel Log Viewer http://mitchmckenna.com/post/15613/laravel-log-viewer

Add a route to your site/app so you can view the logs files to view errors and anything else your app logs.

]]>
Mon, 06 Jul 2015 13:40:00 -0400 http://mitchmckenna.com/post/15613/laravel-log-viewer/laravel-log-viewer
Socialite Providers - 70+ Social Providers for Laravel Socialite http://mitchmckenna.com/post/15508/socialite-providers-70-social-providers-for-laravel-socialite

This allows numerous providers to be used in addition to the ones provided by Laravel Socialite (and they can be overridden easily). You can also easily create your own new providers.

]]>
Mon, 18 May 2015 16:54:00 -0400 http://mitchmckenna.com/post/15508/socialite-providers-70-social-providers-for-laravel-socialite/socialite-providers-70-social-providers-for-laravel-socialite
Laravel Potion - Asset Manager for Laravel 5 based off of Assetic http://mitchmckenna.com/post/15294/laravel-potion-asset-manager-for-laravel-5-based-off-of-assetic

Although Laravel now ships with an asset manager; Elixir, maybe you're in a situation you can't use NodeJS or you'd be more comfortable with a PHP solution instead of NodeJS. Laravel Potion also has the added benefit of CDN support built in which Elixir does not.

]]>
Tue, 24 Mar 2015 17:14:00 -0400 http://mitchmckenna.com/post/15294/laravel-potion-asset-manager-for-laravel-5-based-off-of-assetic/laravel-potion-asset-manager-for-laravel-5-based-off-of-assetic
Doctrine cli-config.php for Laravel 5 http://mitchmckenna.com/post/15205/doctrine-cli-configphp-for-laravel-5

Doctine requires a custom made cli-config.php file for Setting up the Commandline Tool with a Laravel 5 application. The CLI tool is necessary when you need to for example clear Doctrine Cache using php vendor/bin/doctrine orm:clear-cache:metadata.

The following is what you can put in your cli-config.php:

<?php

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;

// replace with file to your own project bootstrap
/** @var Illuminate\Foundation\Application $app */
$app = require_once __DIR__ . '/bootstrap/app.php';

/** @var Illuminate\Contracts\Console\Kernel $kernel */
$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
$kernel->bootstrap();

$app->boot();

// replace with mechanism to retrieve EntityManager in your app
$entityManager = $app[EntityManager::class];

return ConsoleRunner::createHelperSet($entityManager);


Note you will need to have already registered the EntityManager with your app through a service provider. You can use a package like mitchellvanw/laravel-doctrine or opensolutions/doctrine2bridge-l5 to setup Doctrine in Laravel 5.

]]>
Tue, 24 Feb 2015 02:53:35 -0500 http://mitchmckenna.com/post/15205/doctrine-cli-configphp-for-laravel-5/doctrine-cli-configphp-for-laravel-5
Multiple Database Slaves in Laravel http://mitchmckenna.com/post/15201/multiple-database-slaves-in-laravel

Little hack to support multiple read-only slaves in Laravel. There really should be native support for multiple slaves.

]]>
Fri, 20 Feb 2015 16:35:00 -0500 http://mitchmckenna.com/post/15201/multiple-database-slaves-in-laravel/multiple-database-slaves-in-laravel