![data_forget Helper for Laravel](https://laravelsage.com/storage/media/25/conversions/data_forget-helper-responsive.jpg)
data_forget Helper for Laravel
Since Laravel version 10.15, there is a new utility function called data_forget that allows you to remove keys from an array or object using a "dot" notation.
3 min read
Tags:
We'll explore the Laravel Mail Switcher and walk you through its installation steps. Laravel is one of the most popular PHP frameworks when it comes to web applications, as email is a cornerstone of modern communication. Although Laravel has an excellent built-in email system, sometimes you need more control. In this article,
Designed to improve the flexibility and control of email configuration in your Laravel projects. By switching between different mail drivers with this package, you can manage a variety of email services or configurations for a variety of environments more easily.
Using Laravel Mail Switcher, you can switch between different email configurations dynamically, which is particularly useful if you need different settings for local development, staging, and production.
You can use a variety of email drivers, such as SMTP, Mailgun, Sendmail, and more, to meet your specific email requirements.
The installation and configuration is straightforward, making it accessible to developers of all levels.
Here are the steps for installing:
To install the Laravel Mail Switcher package, you'll need Composer. In your project's root directory, run:
composer require sethsandaru/laravel-mail-switcher
Step 2: Migrate
php artisan migrate
Step 3: Configuration
Once the package is installed, you can add email credential by running below php artisan command
//To add
php artisan ms:add
// To Delete
php artisan ms:delete {credentialId}
//Reset Threshold of expired Credentials
php artisan ms:reset
Step 4: Configuration File
Open the config/mail-switcher.php
file in your text editor. Here, you can define different mail configurations for various environments. For example:
return [
'default' => env('MAIL_DRIVER', 'smtp'),
'connections' => [
'smtp' => [
'driver' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.sendgrid.io'),
'port' => env('MAIL_PORT', 587),
'username' => env('MAIL_USERNAME', 'username'),
'password' => env('MAIL_PASSWORD', 'password'),
],
'mailgun' => [
'driver' => 'mailgun',
'domain' => env('MAILGUN_DOMAIN', 'domain'),
'secret' => env('MAILGUN_SECRET', 'secret'),
],
// Add more configurations as needed
],
];
Step 5: Usage
To switch between mail drivers, you can use the MailSwitcher
facade in your Laravel application. For example:
use MailSwitcher;
MailSwitcher::to('mailgun')->send(new MyMailable());
You can change the 'mailgun'
value to any configuration defined in your mail-switcher.php
file.
Laravel Mail Switcher simplifies email configuration management in Laravel projects. With its dynamic configuration capabilities and support for multiple drivers, it's a valuable addition to your Laravel development toolkit. With these installation steps, you can seamlessly integrate it into your project and take control of your email settings.
Complete Documentation can be found at the repository
Full-stack developer with a knack for Merging creativity with technical expertise for standout solutions.
Since Laravel version 10.15, there is a new utility function called data_forget that allows you to remove keys from an array or object using a "dot" notation.
The ChatGPT Laravel API Package Generator package for Laravel generates smart API mocks in Laravel using ChatGPT prompts:
You can make your Laravel app multi-tenant using the Tenancy for Laravel Tenant package. This tenancy package lets you make any Laravel application multi-tenant without rewriting it.
Are you ready to take your Laravel skills to the next level and build extraordinary applications? Look no further! In this blog post, we will unveil a treasure trove of top packages that will revolutionize your development process.
The Livewire Tables package brings dynamic tables for models to Laravel Livewire. These are some of the features which you will get out of the box:
The MJML PHP package by Spatie can help you create email templates more easily. But there is a catch. It can be difficult to craft visually appealing and functional email templates that work across a variety of email clients.
Subscribe for 20+ new Laravel tutorials every week
You can unsubscribe at any time. You'll also get -20% off my courses!