![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:
Laravel Modules for building modular and organized applications. Follow our installation guide to get started with Laravel Modules.
In the world of web development, modularity is a key principle. A powerful tool for achieving modularity in your applications is Laravel Modules, one of the most popular PHP frameworks. Moreover, Laravel Modules allow developers to break down complex applications into smaller, manageable pieces. A detailed explanation of what Laravel Modules are and how to install and use them will be provided in this article.
It is a method of organizing your Laravel application into reusable, self-contained modules or packages, also known as "Laravel Package Development." This approach not only enhances code organization, but also improves code reusability and maintainability by encapsulating routes, controllers, views, migrations, and more. Each module can contain its own routes, controllers, views, migrations, and more.
The following are some benefits of using Laravel Module:
Structure your application's codebase logically and efficiently with modules.
Modules can be reused across multiple projects, saving you time and effort.
Each module is isolated, reducing the risk of conflict between parts.
By isolating related functionality, modules encourage a clear separation of concerns.
After understanding the benefits of Modules, let's see how to install them.
Installing nwidart/laravel-modules is the first step in using Modules, as this package provides the necessary tools and commands.
composer require nwidart/laravel-modules
Next, you'll need to register the Modules service provider. Furthermore, open the config/app.php file and add the following line to the providers array:
Nwidart\Modules\LaravelModulesServiceProvider::class,
To customize the configuration of Modules, you can publish the configuration file using the following Artisan command:
php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
You can define module-related settings in config/modules.php.
Now that Modules is installed, you can create your first module. Use the following Artisan command to generate a new module:
php artisan module:make MyModule
Replace MyModule
with the name of your module.
Upon creating the module, you can create various components within it, such as controllers, models, views, routes, and more. For example, to create a controller, run:
php artisan module:make-controller MyController MyModule
Routes can be defined for each module by creating a routes.php file in the module's directory. Additionally, you can use standard Laravel routing techniques in this file.
In order to enable autoloading for Laravel module, open the composer.json file in your project and add the following to the psr-4 section:
"Modules\\": "Modules/"
After making this change, run composer dump-autoload
to update the autoloaded classes.
If your module includes database migrations and seeders, run the following Artisan commands:
php artisan module:migrate MyModule
php artisan module:seed MyModule
The module is now ready for access. Furthermore, you can navigate to its routes, use its controllers, and utilize any other components you created.
It improves code organization, encourages code reusability, and simplifies project maintenance by structuring your Laravel applications into reusable and isolated. By following the installation steps outlined in this article, you'll be well on your way to building modular Laravel applications efficiently and effectively. Have fun coding!
You'll find installation instructions and full documentation on Module Docs
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!