Download the PHP package avoqado-dev/laravel-usecase without Composer

On this page you can find all versions of the php package avoqado-dev/laravel-usecase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-usecase

๐ŸŽฏ Laravel UseCase

A lightweight, type-safe Use Case pattern implementation for Laravel with built-in business rule validation

Tests Latest Version Total Downloads License GitHub Stars


๐Ÿ“– Table of Contents


๐ŸŽฏ What is Laravel UseCase?

Laravel UseCase brings clean architecture principles to your Laravel applications by implementing the Use Case pattern (also known as Application Services or Command/Query pattern). It helps you organize your business logic into focused, testable, and reusable units that are completely independent of your HTTP layer.

Instead of fat controllers or bloated models, your business logic lives in dedicated Use Case classes that can be called from anywhere - controllers, jobs, commands, or even other use cases.

The Problem It Solves


๐Ÿš€ Why Use This Package?

โœจ Benefits

Benefit Description
๐ŸŽฏ Separation of Concerns Business logic is completely isolated from HTTP, making it reusable across controllers, jobs, commands, and tests
๐Ÿ”’ Type Safety Full PHP 8.2+ type hints and generics catch errors at compile time, not runtime
๐Ÿงช Testability Test business logic in isolation without booting the HTTP layer or database
๐Ÿ“ฆ Maintainability Clear, predictable structure makes onboarding new developers faster
โ™ป๏ธ Reusability Use cases can be called from anywhere - no duplication needed
๐ŸŽจ Business-First Domain rules are first-class citizens with dedicated validation layer
๐Ÿ”ง Laravel-Native Uses familiar Laravel patterns - facades, container, middleware, events
๐Ÿ“Š Observability Built-in logging, caching, and transaction management
โšก Performance Automatic caching and atomic locks prevent redundant work
๐Ÿ›ก๏ธ Safety Database transactions and retry logic built-in

โœจ Key Features


๐Ÿ“ฆ Installation

Install via Composer:

The package will auto-register via Laravel's package discovery.

Publish Configuration (Optional)


๐Ÿš€ Quick Start

1. Generate a Use Case

The easiest way to create a new use case is using the artisan command:

This generates both the Request and Handler classes in app/UseCases/{Module}/{Entity}/{UseCaseName}/.

2. Define Your Request

3. Implement Your Handler

4. Dispatch from Anywhere


๐Ÿ”ง Middleware Explained

Laravel UseCase includes powerful middleware to handle cross-cutting concerns automatically. Simply implement the corresponding interface on your Request class!

1. ๐Ÿ”„ Database Transactions

What it does: Automatically wraps your use case in a database transaction with retry logic.

When to use: Any operation that modifies data and needs atomicity (create, update, delete operations).

Benefits:

Example Use Cases:


2. ๐Ÿ’พ Caching

What it does: Automatically caches the result of your use case to avoid redundant computation.

When to use: Read-heavy operations with expensive computations or database queries.

Benefits:

Example Use Cases:


3. ๐Ÿ”’ Atomic Locks

What it does: Prevents concurrent execution of the same use case using Laravel's atomic locks.

When to use: Operations that must not run simultaneously (payment processing, inventory updates).

Benefits:

Example Use Cases:


4. ๐Ÿ“– Read from Write Database

What it does: Forces read operations to use the write database connection (master) instead of read replicas.

When to use: When you need to read immediately after a write to avoid replication lag.

Benefits:

Example Use Cases:


5. ๐Ÿ“ Logger Middleware

What it does: Automatically logs use case execution (request received, success, failure).

When to use: Enabled by default for all use cases (can be disabled in config).

Benefits:

Log Output:


๐ŸŽฏ Combining Middleware

You can combine multiple middleware on a single use case:

Execution Order:

  1. Logger (request received)
  2. Read from Write Database
  3. Atomic Lock (acquire)
  4. Cache (check)
  5. Database Transaction (begin)
  6. Your Handler Logic
  7. Database Transaction (commit)
  8. Cache (store)
  9. Atomic Lock (release)
  10. Logger (success/failure)

๐ŸŽจ Business Rules

Business rules represent domain-specific validation that goes beyond simple input validation. They encapsulate your business logic and can be tested independently.

Creating a Business Rule

Using Business Rules

Pattern Matching on Exceptions


๐Ÿงช Testing

The package provides comprehensive testing utilities for both use cases and business rules.

Testing Use Cases

Testing Business Rules

Testing Broken Rules


โš™๏ธ Configuration

Customize the package behavior in config/usecase.php:

Middleware Order

Logging

Business Rule HTTP Status


๐Ÿ’– Support & Contribution

โญ Star This Repository

If you find this package useful, please consider giving it a star on GitHub! It helps others discover the package and motivates us to continue improving it.

GitHub Stars

๐Ÿค Contributing

We welcome contributions! Whether it's:

Please see CONTRIBUTING.md for details on our code of conduct and development process.

๐Ÿ“ฃ Spread the Word

Help us grow the community:

๐Ÿ’ฌ Get Help


๐Ÿ“„ License

MIT License - see LICENSE file for details.


๐Ÿ‘จโ€๐Ÿ’ป Credits

Created and maintained by:


Made with โค๏ธ for the Laravel community

โญ Star us on GitHub โ€ข ๐Ÿ› Report Bug โ€ข ๐Ÿ’ฌ Discussions


All versions of laravel-usecase with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0|^13.0
illuminate/container Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/cache Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package avoqado-dev/laravel-usecase contains the following files

Loading the files please wait ...