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

Laravel News:
Laravel 5.3 changes the “app” folder
Jul 22, 2016 @ 09:25:24

On the Laravel News site there's a new article posted about a big change coming to the "app" folder in Laravel-based applications (hint: it's moving towards more simple, not more complex).

As we are getting closer to the launch of Laravel 5.3 new features, seem to come out almost daily. The latest is a change to the “App” folder and in a move to simplify it, the Events, Jobs, Listeners, and Policies folders are now gone.

You can still get them back if you "artisan make" something that fits in one of these four folders but, as they're not really "required" by default they were removed to do some de-cluttering. If you want to find out more about what else is coming/changing in Laravel 5.3, check out this other article also on the Laravel News site.

tagged: laravel changes application app folder events jobs listeners policies

Link: https://laravel-news.com/2016/07/laravel-5-3-changes-app-folder

Adam Wathan:
Customizing Keys When Mapping Collections
Jul 19, 2016 @ 10:52:29

Adam Wathan has a new post to his site talking about mapping with collections and customizing the keys when injecting new data into your Laravel collections.

People often ask me, “how do I specify keys when I’m mapping a collection?”

It actually ends up being a pretty interesting topic, so I decided to cover it in a short screencast, as well as in written format below.

He shows how to translate a simple set of data into a much more slimmed down version. He points out that the "map" function could be used but it doesn't allow for setting keys. Instead he talks briefly about how the problem could be solved in Javascript (returning an object instead of an array) and how to use the "reduce" method to filter and reset the data as it goes through the array. He finishes out the post talking about learning from other languages, the "toAssoc" macro on Laravel collections and mapping the data back to an array with a custom macro.

tagged: customize key mapping collection laravel object javascript example screencast

Link: https://adamwathan.me/2016/07/14/customizing-keys-when-mapping-collections/

Matt Stauffer:
Advanced operations with Collection::where in Laravel 5.3
Jul 15, 2016 @ 11:35:44

Matt Stauffer has continued his series looking at new features in Laravel 5.3 with a look at advanced operations on collections, specifically related to the "where" handling.

If you want to filter a Laravel collection to only those records which meet particular criteria, you're most likely going to reach for filter() or reject(). [...] You might not know it, but there's also a where() method that's pretty simple that gives you the same functionality.

He points out the main difference in Laravel 5.3 - the change from a strict check (the ===) to looser checking (==) and the ability to modify the operation to your liking. He also links to more information about this and other methods in the Laravel code on GitHub.

tagged: laravel collection where laravel53 feature series part6

Link: https://mattstauffer.co/blog/advanced-operations-with-collectionwhere-in-laravel-5-3

Implementing Smart Search with Laravel and Typeahead.js
Jul 14, 2016 @ 12:12:41

The Scotch.io blog has posted a tutorial combining Laravel and the Typeahead.js library to create a "smart search" in your application. Most of the tutorial centers around the Typeahead.js code though, so with a bit of tweaking it could sit on top of just about any framework out there.

In a big web application, like an online market or a social network, one of the most important parts of the app is the search functionality. Having a great search feature will help your users find the right content(users, products, articles) quickly and easily.

In this tutorial, we are going to learn, how to enhance your default search field in your site with real-time suggestions from the database. We will be using Laravel, jQuery and Typeahead (Bloodhound as the suggestion engine) to implement the smart search and Bootstrap for the styling. So, let's get started.

He starts off by introducing the Typeahead.js library and the Bloodhound suggestion engine. He shows the installation (either via Bower, standalone download or included from a CDN) and a simple template with a search form and other Javascript requirements included. The tutorial covers some of the options you can set, what kinds of datasets it can work with and templates to use for the results. Next up, he brings in a default Laravel project and a "search" endpoint that queries user data and returns a JSON dataset of the results. The two pieces are then finally tied together with a few updates to the Javascript already created.

tagged: smart search tutorial laravel typeaheadjs javascript bloodhound

Link: https://scotch.io/tutorials/implementing-smart-search-with-laravel-and-typeahead-js

Nicolas Widart:
Writing modular applications with laravel-modules
Jul 13, 2016 @ 11:57:39

In a new post to his site Nicolas Widart introduces you to the idea of building Laravel applications a bit differently than you may normally: in a more modular structure. This structure makes use of this package to make it happen.

Let me start by saying Laravel is an amazing framework. However when it comes to writing more complex and bigger applications, I find the default structure laravel comes with cumbersome and not ideal.

The way the default laravel installation comes with is basically all the application logic inside an app/ folder. This works, but I would not suggest going this route. [...] This is what being modular is trying to resolve. You split of the business logic into different parts, which belongs together. If you're into Domain Driven Design, you can consider a module an aggregate.

Each module has its own resources (routes, models, views, etc) combined into a single "drop-in" structure. He provides an example of this structure and compares it to the more traditional Laravel "all-app" structure. The package he links to makes this modular structure simpler and points out that this system is what the AsgardCMS already uses behind the scenes.

tagged: modular application laravel tutorial example package asgardcms

Link: https://nicolaswidart.com/blog/writing-modular-applications-with-laravel-modules

Laravel News Podcast:
LN 21: Laracon Live Stream, Laravel 5.3 Collection Where Changes
Jul 13, 2016 @ 09:15:02

The Laravel News podcast has posted their latest episode today - Episode #21: Laracon Live Stream, Laravel 5.3 Collection Where Changes.

In this episode, we discuss Laracon Live Streaming, the new advanced where for Collections, and a few new apps and packages.

Other topics mentioned include the release of the first stable version of the OctoberCMS, the Laravel Password package and an article about anonymous functions. You can listen to this latest show either using the in-page audio player or by subscribing on iTunes or Google Play and also get future episodes as they're released.

tagged: laravelnews laravel podcast news ep21 ericbarnes laraconus collection packages

Link: https://laravel-news.com/2016/07/ln-21-laracon-live-stream-laravel-5-3-collection-changes/

Matt Stauffer:
New JSON-column where() and update() syntax in Laravel 5.3
Jul 11, 2016 @ 11:03:49

In his continuing series of posts looking at the new features in Laravel 5.3, Matt Stauufer has posted this guide to the use in the new JSON column functionality MySQL now provides in recent versions.

While Laravel has had the ability to cast your data to and from JSON since version 5.0, it was previously just a convenience—your data was still just stored in a TEXT field. But MySQL 5.7 introduced an actual JSON column type.

Laravel 5.3 introduces a simple syntax for lookups and updates based on the value of specific keys in your JSON columns.

He gives an example of a simple table with a JSON column storing some metadata for the entry. He includes a bit of example content showing the full entry and related metadata and the where format for querying it. It also includes the ability to run updates on the data just like with any other where clause.

tagged: laravel jon column mysql tutorial series part5 feature

Link: https://mattstauffer.co/blog/new-json-column-where-and-update-syntax-in-laravel-5-3

Matt Stauffer:
The new cache() global helper in Laravel 5.3
Jul 08, 2016 @ 11:11:28

Matt Stauffer has continued his series covering some of the new features in Laravel v5.3 with this look at the cache helper, a new feature introduced to help make working with your cached data easier.

As I was writing my book I noticed a pattern in the global helper functions like session() and, in some ways, cookie(). There are three primary functions that they can perform: get a value, put a value, or return an instance of their backing service.

[...] I mentioned that it seems like there should be a cache() helper, and before I could even think much more about it, Jeffrey (Way) had already written one up. So! Behold! The global cache() helper, new in Laravel 5.3.

He includes code samples showing the helper in action. It's a simplified helper so the main functionality is basically the same as the session and cookie helpers: read, write and return an instance of the CacheManager.

tagged: cache global helper laravel cachemanager overview

Link: https://mattstauffer.co/blog/the-new-cache-global-helper-in-laravel-5-3

Laravel News Podcast:
Episode #20 - With special guest Adam Wathan
Jun 30, 2016 @ 18:20:24

The Laravel News podcast, as hosted by Eric Barnes has posted their latest episode: Episode #20: With special guest Adam Wathan.

In this week’s Laravel News podcast we have Adam Wathan on to talk about his book Refactoring to Collections and a new package MailThief.

You can listen to this latest episode either through the in-page audio player or by subscribing through iTunes or Google Play. There's also a special discount code included for Adam's "Refactoring with Collections" book if you're interested.

tagged: laravelnews podcast ep20 adamwathan laravel collections mailthief

Link: https://laravel-news.com/2016/06/ln-20-special-guest-adam-wathan/

Freek Van der Herten:
A package to log activity in a Laravel app
Jun 30, 2016 @ 09:46:17

In a new post to his site Freek Van der Herten shares information about a logging package they've developed for Laravel-based applications to make activity logging simpler throughout the app: laravel-activitylog.

n your apps there’s probably a lot going on. Users log in and out, they create, update and delete content, mails get sent and so on. For an administrator of an app these events provide useful insights. In almost every project we make at Spatie we log these events and show them in the admin-section of our site. [...] We made a new package called laravel-activitylog that makes logging activities in a Laravel app a cinch. In this blogpost I’d like to walk you through it.

He then goes through the basics of using the library, complete with code examples:

  • simple activity logging with messaging
  • providing the "acted on" object information
  • logging the information about who the actor was

There's also a section with details on automatic model logging, making it easier to see the changes on you data without having to log each one individually. He also shows you how to use multiple logs, providing a method to narrow down log records by type.

tagged: laravel application logging package example introduction model

Link: https://murze.be/2016/06/package-log-activity-laravel-app/