The Blog

Laravel

Laravel

Laravel Facades Part One: An Introduction to Facades

John Koster
John Koster
November 21, 2016

This article is part of a four-part series on Laravel facades. Facades provide a convenient way to access components in Laravel. Each facade is bound to a component registered in the service container. Facades act like proxies, providing a static interface to an actual class instance.

Laravel

Laravel Facades Part Three: Creating Custom Facades

John Koster
John Koster
November 21, 2016

This article is part of a four part series all about Laravel facades. It covers how to create a facade class, register it with the service container, and use it in your application. The article also discusses creating a facade alias, which is optional. Examples are provided throughout the article to illustrate the concepts.

Laravel

Laravel Facades Part Two: Using Facades

John Koster
John Koster
November 21, 2016

Learn about Laravel facades in this four-part series. Part One provides an introduction to facades, while Part Two explains how to use them. Part Three dives into creating custom facades, and finally, Part Four offers a facade class reference. Facades are a convenient way to use static classes that redirect method calls to actual class instances. They allow for shorter and more readable code, though dependency injection is an alternative worth considering.

Laravel

Laravel Fluent Part One: Introduction

John Koster
John Koster
November 21, 2016

Learn how to work with Laravel's Fluent API in this two-part series. Discover how the Illuminate\Support\Fluent class offers a convenient way to handle data, making it easier to make assumptions and avoid errors. Find out how to access data from arrays and objects using Laravel's helper functions, and see how the Fluent class can simplify your code by allowing you to retrieve data with ease.

Laravel

Laravel Fluent Part Two: The Public API

John Koster
John Koster
November 21, 2016

This article is part of a two part series covering the Laravel Fluent API. The first part introduces the API, while the second part focuses on the public API. The article discusses the get method which retrieves values from a Fluent instance, as well as the getAttributes, toArray, jsonSerialize, and toJson methods. It also explains how closures work with Fluent and demonstrates how to handle deeply nested data structures when using the toJson method.

Laravel

Laravel Macros: An Easy Way to Extend Laravel Components

John Koster
John Koster
November 21, 2016

Learn how to use macros in Laravel to add custom functionality and reduce code. Macros in Laravel are similar to extension methods in C#. For example, you can add a countWords macro to the Str support class. Macros can be used in both static and instance contexts and have access to all private and protected members of the class. The Macroable trait provides methods to create macros and check for their existence. A few Laravel components, such as the Eloquent Builder, also support macros.

Laravel

Laravel Miscellaneous Helper Function: data_fill

John Koster
John Koster
November 21, 2016

The data_fill helper function is similar to the data_set helper function, but it does not overwrite existing data. It internally calls the data_set function with the $overwrite parameter set to false. With data_fill, you can set data without worrying about overwriting existing values. The function calls data_fill and data_set in the provided example code would produce the same results.

Laravel

Laravel Miscellaneous Helper Function: data_get

John Koster
John Koster
November 21, 2016

Learn how to use the data_get function in PHP to retrieve values from arrays or objects. Find out how it differs from array_get and object_get and how it can be used with both arrays and objects as the target.

Laravel

Laravel Miscellaneous Helper Function: data_set

John Koster
John Koster
November 21, 2016

Learn how to use the data_set helper function in PHP to set the value of an item in an array or object, using dot notation. You can specify the $overwrite parameter to determine whether existing values should be replaced. See code examples for basic usage and setting nested properties. The function works the same way with objects as it does with arrays.

Laravel

Laravel Miscellaneous Helper Function: dd

John Koster
John Koster
November 21, 2016

The dd() function is a debugging utility in PHP that allows you to dump and display the values of variables. It will provide a human-readable representation of the values and halt the execution of the script. This function is useful for debugging and inspecting variable values during development.

Latest posts

Where Things get Good: Moving on to Forte Development Phase 1

Wrapping up Forte Phase 0 with the lexer and parser now in private alpha, and kicking off Phase 1 wi...

Read more
Forte Update: Backtracking, Metadata, HTML Validation, and More

A Forte development update: the parser now supports backtracking, improvements to node metadata, ide...

Read more
Parsing HTML and Blade Attributes in Forte

Wrapping up attribute parsing in Forte's HTML parser, from simple HTML attributes to complex, edge-c...

Read more
Switch Statements and Parser Extensions in Forte

Exploring how Forte's parser extensions can be used to handle complex Blade directives like nested s...

Read more
Parsing Blade Comments in Forte

Digging into parsing Blade and HTML comments while building Forte's HTML parser for Laravel Blade.

Read more
Thoughts on HTML Elements and Blade Components in Forte

This week I’m tackling Forte's HTML parser - consolidating Blade, Flux, and Livewire components into...

Read more