Search

The blog - deep space.

The Laravel Framework Console Kernel

Dec 1, 2016

Learn about the different public methods provided by the console kernel, such as all to get all registered commands, registerCommand to register a command, and call to execute an Artisan command. Use the output method to retrieve the output from the last executed command. Alternatively, use the queue method to process the command in the background using queue workers.
Writing Custom Laravel Artisan Commands: An Introduction

Dec 1, 2016

Learn how to create custom Artisan commands in Laravel. By default, custom commands are stored in the app/Console/Commands directory. The Inspire command, which displays random quotes, is included in Laravel's framework. You can re-implement this command as a class stored within the app/Console/Commands/ directory. Basic commands need a signature, description, and the handle() method. If you encounter a "Command not found" error when executing the command, check that it has been included in the application's console commands.
An Introduction to Laravel's Artisan Console

Nov 30, 2016

The Artisan Command Line Environment (CLI) is a terminal-based application that eases development with Laravel. It comes with many default commands and APIs to create custom commands. The commands are organized by namespaces and can be used to generate database tables, manage existing tables, or clear various application caches. To manage database tables, you can use commands like migrate, migrate:install, migrate:refresh, migrate:reset, migrate:rollback, and migrate:status. Additionally, there are commands to create migrations for cache, queue jobs, and sessions tables. For cache management, there are commands like cache:clear, config:cache, config:clear, route:cache, route:clear, and view:clear. These commands can be used to flush application cache, improve configuration and router performance, and clear compiled view files. The CLI also provides default Artisan commands that will be discussed in detail in the following sections.
Creating a Hashing Manager For Our Custom Laravel Hashing Implementations

Nov 30, 2016

Learn how to work with different hashing implementations in PHP by using the HashManager class. This class allows you to easily create hashes using various algorithms such as CRYPT_STD_DES, CRYPT_EXT_DES, MD5, CRYPT_SHA256, and CRYPT_SHA512. You can also work with instances of the Hasher class, making it even more flexible. No need to create a facade for the Hasher class, as it's unnecessary in this case.
Creating a Service Provider For Our Custom Laravel Hashing Implementations

Nov 30, 2016

This article explains how to create a service provider for custom hashing implementations in Laravel. It provides links to articles with detailed explanations on creating specific hashing implementations. The article also includes code examples to register different hashing implementations with the application service container, using a service provider named HashServiceProvider. The service provider binds each implementation with a specific name for easy referencing.
Encrypting and Decrypting Within Laravel Applications

Nov 30, 2016

Laravel provides support for AES encryption, a symmetric key encryption scheme, right out of the box. The framework automatically signs all encrypted values with a message authentication code (MAC) to detect any modifications to the encrypted data. Laravel offers a simple API for interacting with encryption services through the Illuminate\Contracts\Encryption\Encrypter interface. There are two implementations of Encrypter shipped with Laravel: Illuminate\Encryption\Encrypter and Illuminate\Encryption\McryptEncrypter. Users can configure the encryption key and cipher in the config/app.php configuration file. Encryption keys must be a random, thirty-two character long string. Decrypting data is as simple as calling the decrypt($payload) method on an Encrypter implementation. Additionally, Laravel provides the Illuminate\Support\Facades\Crypt facade to easily access encryption capabilities.
Laravel: Available Hashing Methods

Nov 30, 2016

Learn about the different hashing functions available in PHP and their security levels. These functions, such as CRYPT_BLOWFISH and CRYPT_SHA256, can be used with Laravel's Illuminate\Contracts\Hashing\Hasher interface. See the alphabet table for the characters used in the hashing functions, and find out how to implement each function in your Laravel project. Additionally, a Hasher class will be created to interact with all the hashing functions and a service provider class will register everything with the service container.
Laravel Collection Public API: __toString

Nov 30, 2016

The __toString() method allows a Collection instance to be cast into a string. When casted to a string, the JSON representation of the collection is returned. This can be useful for easily getting the JSON value of a collection without having to manually call the toJson() method. An example is provided to illustrate how to cast a Collection instance into a string.
Laravel Collection Public API: average

Nov 30, 2016

The average method in Laravel is an alias of the avg method. It calculates the average of items within a collection. In the provided example, both avg and average methods result in 12.5 when used on the given collection.
Laravel Collection Public API: avg

Nov 30, 2016

The avg method in Laravel is used to calculate the average of items in a collection. It can be used with arrays or objects and has an optional parameter to specify what property should be averaged. The method supports nested collections and can be used with "dot" notation to specify nested properties. Overall, the avg method is a convenient way to calculate averages in Laravel collections.
Laravel Collection Public API: combine

Nov 30, 2016

The combine method in Laravel is used to combine the keys of a collection with the values of another collection or array. It returns a new collection instance and does not modify the original one. However, both collections/arrays must have the same length for this method to work properly. An error will be thrown if they don't have an equal number of elements.
Laravel Collection Public API: every

Nov 30, 2016

The every method in Laravel can be used to retrieve a subset of a collection based on each item's distance from each other. You can define the distance between each item using the $step parameter, and specify the starting point using the optional $offset parameter. For example, you can retrieve all even numbers from a collection using $collection->every(2), or retrieve every 50th item from a collection using $collection->every(50).
Laravel Collection Public API: except

Nov 30, 2016

The except method in Laravel returns key/value pairs from a collection that are *not* in the specified keys array. You can use it to exclude sensitive data like passwords. By combining it with the toJson method, you can convert the resulting data to JSON format. This allows you to easily remove sensitive information before sending it to an end user.
Laravel Collection Public API: keyBy

Nov 30, 2016

The keyBy method in Laravel is used to create a new Collection instance where the keys of the new key/value pairs are determined by a callback function or a string. This method does not modify the original Collection instance and instead returns a new modified Collection instance. You can use a simple string value or a callback function to determine the keys of the new collection. For example, you can use the id as the key or even create a hash of the id to use as the key.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.