Download the PHP package cariuk/laravel-repository-pattern without Composer

On this page you can find all versions of the php package cariuk/laravel-repository-pattern. 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-repository-pattern

Laravel Repository Pattern

License: MIT PHP Version Laravel Version

A flexible and powerful Laravel package that implements the Repository Pattern with built-in support for CRUD operations, filtering, sorting, pagination, eager loading, and soft deletes.

Features

Requirements

Installation

Install the package via Composer:

The service provider will be automatically registered.

Quick Start

1. Generate a Repository

Use the Artisan command to generate a repository for your model:

This will create app/Repositories/UserRepository.php:

If your model uses SoftDeletes, the command will automatically extend RepositorySoftDelete instead.

2. Configure the Repository

3. Use in Controllers

API Reference

Available Methods

Reading Operations

Creation & Update Operations

Deletion Operations

Soft Delete Operations (only for RepositorySoftDelete)

Request Parameters

Control repository behavior via URL query parameters:

Advanced Usage

Lifecycle Hooks

Override these methods to add custom logic at different stages:

Custom Data Processing

Using Query Modifiers

Query modifiers allow you to add custom conditions to queries:

Working with Relationships

Disable Pagination

Configuration Options

Property Type Default Description
$fillable array [] Allowed fields for mass assignment
$paginationable bool true Enable/disable pagination
$optionalPagination bool false Allow pagination to be disabled via request
$paginatePerPage int 10 Default number of items per page
$sortable bool true Enable/disable sorting
$sortAllowedFields array ['id'] Fields allowed for sorting
$defaultSortField string\|null null Default field to sort by
$defaultSortDescending bool false Default sort direction
$relationable bool false Enable/disable eager loading
$relationAllowed array [] Relationships allowed to be loaded

Best Practices

1. Keep Repositories Focused

Each repository should handle one model:

2. Use Form Requests for Validation

3. Implement Service Layer for Complex Logic

4. Use Type Hints

5. Cache Frequently Accessed Data

Testing

Troubleshooting

Transaction Deadlocks

If you experience transaction deadlocks with nested repositories:

Memory Issues with Large Datasets

For large datasets, disable pagination carefully:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This package is open-sourced software licensed under the MIT license.

Credits

Developed and maintained by Cariuk

Support

If you discover any security vulnerabilities, please email us instead of using the issue tracker.

For general questions and issues, please use the GitHub issue tracker.


All versions of laravel-repository-pattern with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
laravel/framework Version ^12.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 cariuk/laravel-repository-pattern contains the following files

Loading the files please wait ...