The Blog

Laravel

Laravel

Laravel Miscellaneous Helper Function: object_get

John Koster
John Koster
November 21, 2016

The object_get function in PHP allows developers to retrieve properties from an object using dot notation. It is particularly useful when the existence of a property cannot be guaranteed. Examples demonstrate how to retrieve the department name from a sample object, and how to handle cases where a property doesn't exist or to provide a default value for non-existing properties.

Laravel

Laravel Miscellaneous Helper Function: tap

John Koster
John Koster
November 21, 2016

The tap helper function in Laravel allows you to call a callback function with a given value and return the original value. This is helpful when you want to perform multiple operations on a value in a method chain while preserving the original value. The tap function can be used with any type of value and is particularly useful in scenarios where you need to fix the return value of a series of method calls. It was introduced in Laravel 5.3 and can be easily integrated into older Laravel code bases.

Laravel

Laravel Miscellaneous Helper Function: trait_uses_recursive

John Koster
John Koster
November 21, 2016

The trait_uses_recursive function in PHP allows you to fetch an array of all the traits used by a given class or class instance. It includes the traits used by the class as well as any traits used by those traits. This function can be especially useful when you need to understand the structure and relationships between traits in your code.

Laravel

Laravel Miscellaneous Helper Function: value

John Koster
John Koster
November 21, 2016

The value function in this PHP code will return the default value of the supplied $value parameter. If the $value is an instance of the Closure class, the function will execute the closure and return its value. If not, the $value is simply returned. An example with an instance of Closure shows how the function returns the value returned by the closure, while an example without Closure returns the value directly.

Laravel

Laravel Miscellaneous Helper Function: windows_os

John Koster
John Koster
November 21, 2016

The windows_os helper function checks if the server is running a Microsoft Windows® operating system. By using this function, you can simplify the code and write Windows®-specific commands or instructions separately from non-Windows® code. Eliminate the need for a complex check using substr() and strtolower().

Laravel

Laravel Miscellaneous Helper Function: with

John Koster
John Koster
November 21, 2016

The with function in PHP simply returns the supplied object. It allows you to invoke methods on new class instances that are passed as function arguments. An alternative to using the with function is to wrap object instantiation within a pair of parentheses. Both techniques achieve the same result, but the with function may enhance readability and clarify intent.

Laravel

Laravel Router Helper Function: delete

John Koster
John Koster
November 21, 2016

The delete function is used to register a route with the router that will respond to the DELETE HTTP verb. You provide the $uri and the $action that will be executed when the route is matched. The $action can be a closure or a mapping to a controller method. You can also use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: get

John Koster
John Koster
November 21, 2016

The get function in Laravel is used to register a route that responds to the GET HTTP verb. It takes a URI and an action as parameters, where the URI is the path of the route and the action is what will be executed when the route is matched. The action can be a Closure or a mapping to a controller method. The return value of the get function is an instance of the \Illuminate\Routing\Route class. You can also use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: patch

John Koster
John Koster
November 21, 2016

The patch function in Laravel is used to register a route that responds to the PATCH HTTP verb. You can specify the URI of the route and the action that will be executed when the route is matched. The action can either be a Closure or a mapping to a controller method. You can use the patch function directly or use the Route facade or resolve the router from the application container to achieve the same results.

Laravel

Laravel Router Helper Function: post

John Koster
John Koster
November 21, 2016

The post function in Laravel is used to register a route that responds to the POST HTTP verb. You can specify the URI of the route and the action that will be executed when the route is matched. The action can be a closure or a reference to a controller method. You can also use the Route facade or resolve the router from the application container to achieve the same results.

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