In Laravel

Implementing Laravel Artisan Console Commands

Dec 1, 2016

Learn how to create custom commands in Laravel by generating the basic structure or scaffolding for the new command. Use the make:console Artisan command in the terminal, specifying the name of the new command class and the optional terminal command name. The generated scaffolding includes the command class with a $signature and $description property for specifying arguments and options, as well as a handle method to define the command's logic. Register the command in the console kernel and regenerate the Composer auto-loader file if needed.
Laravel Artisan Command Input and Command Signatures

Dec 1, 2016

Learn how to define and use input parameters and options in Laravel Artisan commands. Parameters are required data, while options are not required and can change the behavior of the command. Parameters and options are defined in the command's signature, which is a string constructed using specialized syntax. Arguments are given to command parameters by supplying the value separated by a space. You can also give parameters default values. Descriptions can be added to parameters and options for clarity in the help information. Laravel also supports array parameters and options, as well as option shortcuts. Options can be used as flags or switches to change command execution behavior.
Laravel Artisan Command Input Syntax Reference

Dec 1, 2016

This table provides a quick reference for common command signature definitions. It includes syntax examples, descriptions, and indicates if values are required or optional. Examples include required parameters, adding descriptions to parameters, specifying default values, making parameters optional, accepting arrays of input, defining boolean flags, adding descriptions to options, defining shortcuts, and defining options with default values.
The Laravel Application Console Kernel

Dec 1, 2016

The application console kernel, defined in the app/Console/Kernel.php file, is responsible for specifying which custom commands should be available and when to automatically execute various commands and tasks using the task scheduler. This console kernel extends the Laravel framework console kernel located in the vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php. While being separate sections, the application and console kernels are actually the same thing, differentiated here for explanation purposes. The application console kernel is mainly used for registering commands and scheduling tasks. The kernel class has an empty $commands array and an empty schedule() method, which need to be populated to avoid command not found errors. Commands can be registered using the fully qualified class name or shorthand syntax in the $commands array, and the schedule method can be used to define the application's command schedule. Further details about the Laravel Console kernel can be found in the [The Laravel Framework Console Kernel](/blog/2016/12/01/the-laravel-framework-console-kernel) article.
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.

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.