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

Laravel News:
Creating Your Own Configuration in Laravel
Sep 19, 2017 @ 12:14:16

On the Laravel News site there's a new tutorial posted showing you how to create your own custom configuration for those that are newer to the framework.

If you are new to Laravel, you might not yet know how you can create your configuration files in your projects and a few other helpful things that will help you master configuration. As always, the official documentation provides great information, and there are a few things we’ll cover here that I think will help people new to the Laravel framework.

They walk you through a complete guide to the Laravel configuration handling including:

  • what pieces are involved and where they belong
  • accessing the configuration service
  • working with configuration values
  • creating a custom configuration
  • caching the configuration for better performance

Each item on the list has a brief description helping to illustrate the point and commands/code examples where appropriate.

tagged: laravel configuration custom tutorial introduction

Link: https://laravel-news.com/creating-configuration-in-laravel

Laravel News:
Laravel 5.5 Now Includes TrustedProxy
Sep 15, 2017 @ 11:07:03

On the Laravel News site there's a new post about a feature introduced in version 5.5 of the popular PHP framework: a proxy that's included by default as a part of the TrustedProxy feature.

Laravel v5.5 was released just a week ago at Laracon EU. You may have noticed that the v5.5 composer.json file requires the similar functionality Symfony has).

tagged: laravel proxy package feature cloudflare tutorial framework

Link: https://laravel-news.com/trusted-proxy

Laravel News:
Dynamic templates in Laravel Blade with View::first
Sep 14, 2017 @ 10:54:11

On the Laravel News site there's a tutorial posted showing you how to use Blade's View::first functionality to dynamically show a template if it exists.

When building dynamic components or pages sometimes we want to display a custom template if it exists or otherwise fall back on a default one.

[...] We can solve this problem with a series of conditionals or by using view()->exists() to check if a custom template exists or not, however, Laravel 5.5 brings us a better and more elegant way.

A screencast of the functionality in action is included as well as a text-only version with code samples showing the previously used "if view exists" check and the refactor to use View::first instead.

This dynamic view loading feature was added to Blade in Laravel v5.5 and is a great way of keeping your controllers simple by avoiding extra conditionals when dealing with dynamic templates.
tagged: dynamic template laravel blade view first refactor laravel55

Link: https://laravel-news.com/viewfirst

Nicola Malizia:
Make your Telegram bot with Laravel and BotMan
Sep 13, 2017 @ 09:41:54

Nicola Malizia has written up a post showing you how to create a Telegram bot using Laravel and the BotMan package. BotMan is a project that seeks to make it easier to work with chat commands directly in an application with some handy tools included.

After a long time I’m here to talk about Telegram bots. Lately, I discovered a nice PHP library for building Telegram Bots and I want now to show you it’s potential? - ?BotMan.

BotMan is a framework agnostic PHP library that is designed to simplify the task of developing innovative bots for multiple messaging platforms, including Slack, Telegram, Microsoft Bot Framework, Nexmo, HipChat, Facebook Messenger, WeChat and many more.

The best part of this library is that you can integrate with Laravel, thus taking benefit of the vast ecosystem around it.

He then walks you through the installation of the BotMan package and creation of a simple "Hello world" kind of bot. He then shows how to install the driver for the Telegram. He then shows how to connect the bot to Telegram, execute it and expose it to the world via ngrok and how to test it out. He finishes the post with a more real world situation: creating a bot that allows users to subscribe and receive broadcasts when an announcement is made.

tagged: botman chatbot tutorial laravel telegram subscribe

Link: https://unnikked.ga/make-your-telegram-bot-with-laravel-and-botman-b8199e58461d

Tighten.co:
Extending Models in Eloquent
Sep 12, 2017 @ 09:45:45

On the Tighten.co blog there's a new tutorial posted by Caleb Porzio showing you how to correctly extend Eloquent models in a Laravel application.

When starting out with Eloquent, it’s natural to reach for familiar operations like where and join. For more advanced users, features like scopes, accessors, and mutators offer more expressive alternatives to the query-building patterns of old.

Let’s explore another alternative that can be used as a stand-in for repetitive where statements and local scopes. This technique involves creating new Eloquent models that extend other models. By extending another model, you inherit the full functionality of the parent model, while retaining the ability to add custom methods, scopes, event listeners, etc. This is commonly referred to as “Single Table Inheritance,” but I prefer to just call it “Model Inheritance”.

He starts with an example using the User model and creating a "local scope" method to answer the "is admin?" question. He then abstracts this out even more with an Admin model that extends the User that can be used instead to refer to admin users only. He includes examples of this in use for notifications, guard classes and model factories. He ends the post with one "gotcha" to this method - the fact that relationships no longer work on the Admin model - and how to work around it.

tagged: laravel eloquent extend model tutorial

Link: https://tighten.co/blog/extending-models-in-eloquent

Jeff Madsen:
Custom Pivot Table Models, or Choosing the Right Technique in Laravel
Sep 11, 2017 @ 11:17:09

Jeff Madsen has some helpful hints for the Laravel (or just Eloquent) developers out there when it comes to models. In this new post to his Medium site he looks at using custom pivot table models (and choosing the right technique to use them).

Laravel is “opinionated”, but that usually just means that there are a lot of defaults set up that push you toward a certain style. Over the years I have found very few cases where you can’t easily override these; more often than not, it is simply a case of adding another function call when you instantiate something.

As I thought about the way I would normally code around Mark’s problem, and then searched and found the more direct answer from the docs, it occurred to me that this was a perfect example.

He starts with the more "standard" way of working with pivot tables in Laravel (code example include) using the updateExistingPivot method. He talks about the difference between writing the code and designing the code, making it more maintainable and well-architected. He talks about moving the logic into a service class but points out a few issues with that approach as well. Finally, in his last option, he covers the special "Pivot" model included with Eloquent and shows it in use.

tagged: custom pivot table model laravel tutorial example

Link: https://medium.com/@codebyjeff/custom-pivot-table-models-or-choosing-the-right-technique-in-laravel-fe435ce4e27e

Laravel News:
The Laravel Podcast Season Three
Sep 08, 2017 @ 10:52:59

On the Laravel News site there's a new post sharing some of the details about the upcoming season three of their podcast in an interview with host Matt Stauffer.

The official Laravel Podcast started back in 2013, and so far it’s been through two “seasons.” The first ran from 2013 through February 2015, with a mixture of guests and topics. Then came season two, which started in March of 2015 with Matt Stauffer as the host and it introduced Taylor Otwell and Jeffrey Way as regular guests/co-hosts.

Today Matt has announced that the podcast is transitioning into its third season of life. I had the opportunity to sit down with Matt to find out what we can expect with this new season.

Matt answers questions about what you can expect from the show in the upcoming year, the shift to an "interview show" and when you can expect the new shows to be released. You can read Matt's answers to these and other questions in the full post.

tagged: laravel podcast season three mattstauffer interview

Link: https://laravel-news.com/laravel-podcast-season-three

Christoph Rumpel:
Build a Facebook Messenger chatbot in Laravel with BotMan Studio 2.0
Sep 08, 2017 @ 09:26:01

Christoph Rumpel has written up a tutorial on his site showing you how to use Larave and the Botman package to create a simple chatbot for use on Facebook.

With BotMan it is really easy to setup a Facebook chatbot. This week the new 2.0 version was released. We will checkout how to setup a Facebook Messenger chatbot in this new version with BotMan Studio.

He starts with a list of requirements to be sure you have installed before proceeding. He then helps you get the Botman software installed and the command to bootstrap a Facebook bot instance. He includes instructions on how to test the bot and how to configure it to work with a Facebook application (requiring relevant token/secret information). From there he shows you how to set up the Facebook application and connect the bot to it via a webhook. The ngrok tool makes this easier as it exposes your local Laravel application on an external URL for testing. Finally, he shows how to test the integration by sending a few sample messages to the bot and getting responses.

tagged: facebook messenger chatbot laravel botman studio tutorial

Link: http://christoph-rumpel.com/2017/09/build-a-facebook-chatbot-with-laravel-and-botman-studio/

North Meets South Podcast:
Managing timelines, wireframing, and nested Laravel applications
Sep 07, 2017 @ 10:47:11

The "North Meets South" podcast, hosted by Jacob Bennett and Michael Dyrynda, has posted their latest episode - Episode #33: Managing timelines, wireframing, and nested Laravel applications.

Jake and Michael continue with their developing journey and share their approaches to managing timelines. They also talk about different wireframing techniques and setup some future episodes with discussion around containing multiple applications in a single Laravel install.

You can listen to this latest episode either using the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter for updates on when new shows are released.

tagged: northmeetssouth podcast ep33 timeline wireframe nested laravel jacobbennett michaeldyrynda

Link: http://www.northmeetssouth.audio/episodes/a309252d/managing-timelines-wireframing-and-nested-laravel-applications

Zeeshan Ahmed:
JWT authentication for Lumen 5.4
Sep 06, 2017 @ 12:44:23

In a recent post to his site ** shows you how to create a system that uses a handy package to create JWT authentication handling for a Lumen-based application. Lumen is the microframework sibling to the Laravel framework.

Recently I have been tinkering with Angular-4 to get a taste of it and I decided to create a quick project to get my hands dirty. I decided to create a blog with authentication etc. My main focus was on the frontend so I decided to quickly bootstrap an application in Lumen because of its simplicity and almost zero-configuration development. For the authentication, I decided to go with JWT and this post is going to be a quick write-up on how I integrated that and how anyone can integrate JWT authentication in their APIs.

He then walks you through the setup of a new Lumen project and populates the database with some sample (faked) user information from a seeder. Next he helps you get the firebase/php-jwt library installed via Composer and creates the matching controller and middleware to wire it into the application. In his example the user is authenticated via the standard username/password form and, when successful, generates a JWT token that's then passed along with other requests for validation by the middleware.

tagged: lumen laravel tutorial jwt authentication token firebase package

Link: https://zeeshanu.github.io/2017/09/05/jwt-authentication-for-Lumen-5.4/