Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Review of Test-Driven Laravel
Dec 02, 2016 @ 10:44:56

The Laravel News site has posted a review of "Test Driven Laravel", a course from Adam Wathan walking you through the creation of a Laravel-based application from a completely Test-Driven Development approach.

I’ve been programming for close to a decade, and I’m constantly trying to find ways so to improve my skill set to be able to keep up with the ever-changing landscape of technology. The one area I’ve always wanted to improve in has been testing. [...] When Adam announced at Laracon that he was creating a course on building real-world applications with TDD, I was really excited to see where it would go.

Over the past couple of months, I’ve been lucky enough to preview the course as the lessons get finished. It’s been really helpful because I’ve been working on a large, complex application, and I’ve been able to apply the things I’m learning immediately in my day-to-day work.

The review goes on to talk about some of the things they've learned already from the course including test coverage for parts of the app that work with 3rd party services. They link to this talk from Adam as an example of some of the concepts taught in the course and, of course, a link where you can purchase your own Early Access pass and start learning.

tagged: review earlyaccess testdriven laravel tdd adamwathan testing course

Link: https://laravel-news.com/review-of-test-driven-laravel

Laravel News:
Quickly Dumping Laravel Queries
Nov 28, 2016 @ 12:49:36

The Laravel News site has a quick post today with a helpful hint for those trying to track down exactly what queries their Laravel application is performing on database calls. In this post they show two ways to get this information - one using the Debugbar and the other with a quick script.

When you are building an application and utilizing Eloquent it’s very easy to hit the N+1 problem. This is where you select a model and then later use lazy loading to fetch child records.

They give an example of selecting a user, grabbing it's list of "posts" and then looping through them causing queries to fire for each post individually. A fix for it is using the "with" method to pre-load them but determining this could be tricky. Enter their two solutions: the Laravel Debugbar package and this quick script shared by magkopian that listens for a "kernel.handled" event and outputs the results of the "getQueryLog" method with the Laravel "dd" helper.

tagged: laravel dump queries debugbar debugging sql database tip

Link: https://laravel-news.com/2016/11/quickly-dumping-laravel-queries/

Laravel News:
Getting started with Watson Personality Insights
Nov 25, 2016 @ 14:52:01

On the Laravel News site there's a post showing an application of the IBM Watson Personality Insights service to discover trends and make predictions about future actions/preferences. They also show how to integrate it into your Laravel-based application thanks to this package.

One of the most important things as a business owner is being able to understand your customers’ needs and wants; such that you are able to offer them a personalized experience. This works great if you know your customers on a personal level, but what if you don’t?

[...] Sure you could send out a survey from your site, then collect a huge amount of data, then process, analyze and finally being able to tell what package fits which user. This seems tiresome and plus people’s tastes and preferences change over time and you would have to repeat this process over and over again each time you want to offer them something new. There has to be a better way, and there is.

The post talks about the services offered by IBM Watson and, more specifically, about Personality Insights. They cover some about what this service offers as related to web preferences and link to a demo application you can use to get more context about its handling. The post wraps up showing how to integrate the package into your application and working with requests/responses to the IBM Watson Personality Insights service.

tagged: ibmwatson personality insights tutorial laravel package machinelearning

Link: https://laravel-news.com/2016/11/getting-started-with-watson-personality-insights/

Joe Ferguson:
Use Laravel Shift for your next upgrade
Nov 24, 2016 @ 09:13:23

In this new post to his site Joe Ferguson takes a look at Laravel Shift, an automated service that makes it easier to upgrade your Laravel-based application quickly.

I’ve had an eye on LaravelShift.com since it first made it’s way across my twitter feed some time ago. I’ve also had the pleasure of meeting and talking with it’s creator Jason McCreary at a few conferences over the past year. I think it’s really awesome when community members are able to take a product to market that not only scratches their own itch, but can provide value to the rest of the community as well.

[...] I built NerdsAreDrinking on Laravel 5.1 because that was the current version at the time. We have seen two more release since: 5.2 and 5.3. The upgrade process isn’t terrible however there is a lot you may need to take into account. Rather than upgrade from 5.1 to 5.2 and then 5.2 to 5.3 I decided to use Laravel Shift to do the 5.1 to 5.2 upgrade for me.

Joe then talks some about his experience using the service and was impressed at the speed of the service to create the required Pull Request for the update. He includes a link to the PR so you can see what the upgrade looks like too. He feels like the money spent (around $11 USD) was well invested and would definitely use the service again.

tagged: laravel laravelshift upgrade opinion service version

Link: https://www.joeferguson.me/use-laravel-shift-for-your-next-upgrade/

Deployer Blog:
How to deploy Laravel application
Nov 22, 2016 @ 12:39:30

In a new post to their blog the Deployer project (a PHP-based deployment tool) has shared a quick tutorial about deploying Laravel applications using the tool and just a few simple commands.

Apparently you already have some Laravel application and some server or shared hosting. Now you need to automate the process of deployment. Deployer will helps you in this as it ships with some ready to use recipes for Laravel based application.

They start with the details about installing the tool then share the single "dep init" command to create the deployment configuration needed to deploy a default Laravel application. There's a few modifications you'll need to make for your own project (like repository location, server information and the path to your SSH key) but that's basically it. The "dep deploy" command can then be used to push the release to the remote server in a "current" directly ready and waiting for your web server to serve up.

tagged: deployer deployment tool tutorial laravel application setup

Link: https://deployer.org/blog/how-to-deploy-laravel

Laravel News:
Laravel 5.4: JSON Based Language Files
Nov 22, 2016 @ 09:44:33

The Laravel News site has a new post today describing a feature of the upcoming Laravel 5.4 release: the ability to define language files with JSON formatted files.

One of the most wanted requests we receive at Laravel is introducing better support for multilingual web applications, there are already packages out there that add some nice functionality to Laravel for better handling of multilingual projects requirements, but one of the painful issues when building such applications is managing translation keys.

Previously the trans/trans_choice helper to reference the value defined in the PHP array from your language files by a key name. With this new functionality, a new __() helper method is defined that will look through the English translation file, locate the correct key and find the matching record in the requested language to return. They also show how to pass in some parameters into the translator and how to use it directly from Blade.

tagged: laravel json language file helper tutorial parameter blade

Link: https://laravel-news.com/2016/11/json-based-translations/

Alison Gianotto:
Demystifying Custom Auth in Laravel 5
Nov 21, 2016 @ 11:49:17

Alison Gianotto (a.k.a. Snipe) has a new post on her site talking about custom authentication in Laravel-based applications including built-in functionality and how you can override it to your needs.

I’m a big fan of Laravel. I use it in most of my personal and professional projects, and for the most part it really does make coding fun for me again. One of the things Laravel tries to do (similar to Rails) is to build in the most repetitive things a developer would have to do, for example a user registration/login/forgotten password system.

[...] In each of my current Laravel apps, auth works just a tiny bit differently. Add to that the fact that a few of them were pulled forward from Laravel version 4.2, and things can get confusing and messy. [...] Laravel makes this really, really easy – they just don’t document how to do it very well.

She starts by mentioning the "fresh" install version of building out the auth pieces (php artisan make:auth) but points out that, if a more "hybrid" system is needed, a bit more work is required. She shows you the routes that are created in the "make:auth" process and how/where you need to modify things to customize it to your system. She illustrates with some of her own changes including code examples.

tagged: laravel tutorial custom authentication framework

Link: http://snipe.net/2016/11/demystifying-custom-auth-in-laravel-5/

Freek Van der Herten:
An unofficial Forge API
Nov 18, 2016 @ 10:54:09

In this quick post to his site Freek Van der Herten looks at the "unofficial Forge API" you can use to do some (limited) things with your Forge account and servers. Forge is a service in the Laravel ecosystem for managing and deploying servers with a simple and clean frontend interface.

You might not know this but Forge already has an API, it’s just not a documented and feature complete one. Open up your dev tools and inspect the web requests being sent while you do various stuff on Forge.

Marcel Pociot published a new package called Blacksmith (great name Marcel) that can make calls to that API.

The package submits a login form behind the scenes to authenticate but other than that it's normal API calls. The package includes methods allowing you to:

  • get a list of all active servers
  • return server by ID
  • get the listing of sites
  • update metadata
  • get environment information

...among other things. You can find out more about the package in its GitHub repository.

tagged: laravel forge api unofficial package blacksmith

Link: https://murze.be/2016/11/unofficial-forge-api/

Scotch.io:
Laravel Social Authentication with Socialite
Nov 17, 2016 @ 12:17:41

The Scotch.io site has posted a tutorial for the Laravel users out there showing you how to use the Socalite package in your application to make authentication handling with external services simpler.

Laravel introduced a built in Authentication module in version 5.2. To set this up, you just have to run php artisan make:auth and everything is generated for you, from the views to the controllers and the routes.

[...] And that is a great thing. However, this command will only make you a traditional login. In most sites nowadays when signing up, users have the option of signing up with a social provider such as Facebook. In this tutorial, I will teach you how to add multiple social providers to a Laravel app using Socialite package. For this tutorial we will add Facebook, Github and Twitter signups.

They start off with a new Laravel application (but, of course, you can use your current one), setting up a new database and creating a custom "users" table that includes "provider" information. The User model is then updated to allow the population of this data and the "make:auth" command is run. The Socialite package is then included and the application is configured to include its service provider. The tutorial then steps you through creating Github, Twitter and Facebook applications, getting the keys needed to drop into your app's configuration. Finally they update the login/registration pages with the social login buttons and how they'll now "magically" work.

tagged: tutorial socalite authentication laravel github twitter facebook

Link: https://scotch.io/tutorials/laravel-social-authentication-with-socialite

SitePoint PHP Blog:
Interrupting Applications with Laravel Middleware
Nov 16, 2016 @ 12:13:05

The SitePoint PHP blog has a new tutorial posted showing you how to "interrupt applications with Laravel middleware", adding functionality to your request/response handling in a more automatic and reusable way.

Before we launch into using middleware with Laravel, what is middleware? In general, middleware is software that connects different systems to one another. In Laravel, it’s one of the most well known and robust PHP frameworks that are available for use today, middleware provides a way for you to filter out your HTTP requests and manage those requests. This allows you to dictate how those requests interact with your application.

The use of middleware in Laravel 5 can interrupt requests to your application. [...] Laravel’s middleware can interrupt those requests and then perform various actions such as controlling access and requiring authentication to enter certain areas.

They get into some of the details about middleware, how it "interrupts" your requests and then relate it back to its use in Laravel applications. The tutorial talks about using the "artisan" command line tool to make the middleware and an embedded video from their own Laravel series giving even more detail.

tagged: laravel middleware interrupt framework tutorial screencast

Link: https://www.sitepoint.com/middleware-in-laravel-5/