Learn how to create a custom implementation of the Illuminate\Contracts\Hashing\Hasher contract in PHP. This implementation uses PHP's crypt function and the CRYPT_STD_DES hashing algorithm. The implementation includes methods for hashing, checking hashed values, and determining if a hash needs to be rehashed. The implementation also allows for the option of supplying a custom salt. See a complete example of the implementation and usage in the article.
This article explains how to create an implementation of Illuminate\Contracts\Hashing\Hasher in PHP using the crypt function and the CRYPT_MD5 hashing function. The article breaks down each method and provides a complete implementation of the Md5Hasher class at the end. By following this guide, you can create your own custom hashing implementation in Laravel.
The FileLoader class in Laravel is responsible for loading translation files from the file system. By default, the language files are loaded from the /resources/lang/ directory, with each sub-directory within lang/ corresponding to a specific locale. Each locale directory contains PHP files that return key/value pairs for translations. These files are referred to as "groups". The FileLoader implements the LoaderInterface contract, which includes the load and addNamespace methods for loading translations and adding namespaces, respectively. Translation namespaces are used to prevent conflicts between multiple vendors using the same group names for a locale. The * namespace refers to groups in the default /resources/lang directory, and custom namespaces can be added using the addNamespace method.
Learn how to handle pluralization and specific numbers in Laravel's translator. Message tags can be used as comments for different plural translation messages. Laravel allows for handling specific numbers by passing them directly to the translation message. Intervals can also be used in translation messages to match a range of numbers.
Learn about the Bcrypt hasher in Laravel, how to set the number of rounds for the hash calculation, and how to generate and check hashes using the make and check methods. See examples of generating hashes and checking their validity. Also, discover how to determine if a hash needs to be rehashed and how to use the Hash facade to access hasher methods.
The Translator class is responsible for handling interactions between the application and the translation systems. It implements Symfony's TranslatorInterface and provides functions to determine if a translation exists, retrieve translations with replacements, and pluralize translations. The class also allows you to set and get the current locale and fallback locale. You can access the Translator instance from the application container using the translator name.
Learn to use the Illuminate\Support\Collection class in Laravel to manipulate data using familiar array syntax. Access and iterate through the collection using key/value pairs. Retrieve values associated with known keys and work with the underlying array using the toArray method. Be aware that array-specific functions will not work directly on a collection, but can be used on the underlying array. Use methods like get to retrieve data from the collection with the option to return a default value. Create a new collection instance by passing an array of items to the constructor, or by using the make method or the collect helper function.
The Illuminate\Support\MessageBag class is a key/value storage system for storing different types of messages and specifying a format for returning them. It implements both the Illuminate\Contracts\Support\MessageProvider and Illuminate\Contracts\Support\MessageBag interfaces. The MessageProvider interface allows other classes to return MessageBag implementations. This article also provides a list of classes that extend, implement, or make use of the MessageProvider interface. Check out the rest of the articles in the series to learn more about the Laravel ErrorMessageBag component.
The Illuminate\Support\ViewErrorBag class is a container for error messages used to communicate with views and responses. When there are errors in the current request, an instance of ViewErrorBag is shared with views. The ViewErrorBag instance can be accessed using the errors name. The class provides several public methods for interacting with the error bags.
Learn about the public API of the Collection class in this section. With 64 methods, this extensive API allows you to retrieve values, transform arrays, implement pagination, and perform simple aggregates. You'll gain a deep understanding of this powerful class, excluding methods needed for implementing PHP's ArrayAccess and IteratorAggregateinterfaces, as well as the getCachingIterator method.
The past six months or so have been incredibly busy. What started as a new article series about cust...
Read moreIn this post I talk about how I resolved a mysterious illegal offset type error when viewing collect...
Read moreGenerating a custom Laravel routes file from a Statamic website to redirect to a new domain.
Read moreDisabling file hashes in Vite output can be accomplished by modifying your project's vite.config.js
Read moreLearn how to implement a custom component compiler for Laravel's Blade templating language in this p...
Read morePart 5 of 6 covers implementing a cache namespace and labeling system, which we can use to target mu...
Read more