Supercharge Your Laravel Workflow with ZapCraft
In the ever-evolving landscape of Laravel development, where every keystroke matters, a new player has emerged to transform the way developers craft applications. Say hello to ZapCraft, a Laravel package meticulously designed to bring unparalleled efficiency, structure, and elegance to your development workflow.
Why ZapCraft?
In the trenches of development, the journey often involves grappling with repetitive tasks, especially when it comes to setting up new entities. ZapCraft was born out of a developer’s struggle, a response to the monotonous chore of creating the same files repeatedly. This package is not just about saving time; it’s about reshaping the development experience.
Advantages of ZapCraft
1. Effortless Entity Setup:
Say goodbye to the tedious dance of creating models, migrations, controllers, and more for every new entity. ZapCraft simplifies the entire process with a single command, ensuring a consistent and efficient structure for every new component.
2. Consistent Codebase:
ZapCraft isn’t just a tool; it’s a champion of the SOLID principles. Each generated file serves a specific purpose, eliminating redundancy and contributing to a more maintainable and scalable project.
3. Dependent on Laravel-Modules:
Built on the robust foundation of the `nwidart/laravel-modules` package, ZapCraft leverages its modular architecture. This not only ensures a well-organized project but also seamless integration with Laravel applications.
4. Following SOLID and DRY Principles:
ZapCraft embraces SOLID principles, fostering a clean and organized codebase. It also adheres to the DRY (Don’t Repeat Yourself) principle, minimizing redundancy and maximizing efficiency.
Unleashing ZapCraft Magic
Let’s delve into a practical example by running the following command in the root of your Laravel project. Ensure that you have correctly installed and set up the ZapCraft package by referring to the documentation on GitHub
https://github.com/holdmyglass/ZapCraft
php artisan zapcraft:all Product --module=sale
Executing this command will generate the following files within the Sale Module:
- Repositories/ProductRepository.php
- Interfaces/ReadProductRepositoryInterface.php
- Interfaces/WriteProductRepositoryInterface.php
- Services/ProductService.php
- app/Http/Requests/Product/ReadOneProductRequest.php
- app/Http/Requests/Product/ReadManyProductRequest.php
- app/Http/Requests/Product/CreateProductRequest.php
- app/Http/Requests/Product/UpdateProductRequest.php
- app/Http/Requests/Product/DeleteProductRequest.php
- app/Resources/Product/ProductResource.php
- app/Resources/Product/ProductCollection.php
- DTO/ProductDTO.php
- routes/api/product.php
Following this, the route file is automatically added to api.php
, providing a fully functional API endpoint.
The presence of multiple interfaces and request files may raise questions. Typically, the Read API is public, while write, update, or delete operations are restricted to authenticated users. The decision to separate these interfaces aligns with personal preference. Regarding the request files, the existence of five different ones may seem excessive. While request files conventionally serve as a space for validating requests using Laravel validation rules, they also offer an ideal location to check if the requesting user possesses sufficient permissions. By default, the authorization status is set to true, but you can modify it based on your specific requirements.
public function authorize(): bool
{
return true;
}
Upon inspecting any of the generated files, you’ll notice that they are complete logical classes and functions, all following a consistent pattern — a pattern employed during the development phase.
This level of detail and structure is designed to provide flexibility while maintaining a logical and coherent coding approach.
Feel free to explore and modify these files according to your project’s needs, and enjoy the seamless and efficient Laravel development journey facilitated by ZapCraft.
ZapCraft isn’t just a Laravel package; it’s a paradigm shift in how we approach development. Its advantages extend beyond time-saving, reaching into the realms of good coding practices and an enhanced overall development experience.
Try ZapCraft today, and witness the transformation in your Laravel projects. Streamline your workflow, embrace SOLID principles, and redefine your coding journey.
Explore ZapCraft on GitHub and elevate your Laravel development experience!