Download the PHP package gohari/repository-pattern without Composer

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

Gohari Laravel Repository Pattern

Build clean repositories for Laravel models with one Artisan command.

gohari/repository-pattern provides a reusable BaseRepository, a matching BaseRepositoryInterface, and a generator command that creates repository classes inside the Laravel application that installs your package.

Current release: v2.0.0

Documentation: mohammadrezagohari.github.io/RepositoryPattern

Features

Requirements

Installation

Install the package with Composer:

Laravel will discover the service provider automatically:

If package discovery is disabled in your app, register the provider manually in config/app.php:

Publish the config or generator stubs when you want to customize package defaults:

Published stubs live in:

Quick Start

Create a repository for a model:

This creates:

If App\Models\User does not exist, the package will create it with Laravel's make:model command.

Command Usage

Arguments and options:

Name Required Description
name Yes Repository name. User and UserRepository both generate UserRepository.
--model No Model class name or FQCN. Defaults to the repository name.
--path No Output directory. Defaults to app/Repositories.
--interface-path No Repository interface output directory. Defaults to app/Repositories/Contracts.
--force No Overwrite existing repository files.
--bind No Bind the generated interface to the repository in App\Providers\RepositoryServiceProvider.
--service No Generate Service, ServiceInterface, DTO, and config alongside the repository.
--service-path No Service output directory. Defaults to app/Services.
--dto No Generate only the DTO alongside the repository.
--dto-path No DTO output directory. Defaults to app/DTOs.
--config No Copy config/repository-pattern.php into the application.

Examples:

Use a custom output path:

Overwrite existing files:

Create files and register the interface binding:

Generate repository and service layers together:

For fully-qualified model classes outside App\Models, the command will warn you if the model file is missing, but it will not generate it automatically.

Generated Repository

For this command:

The package generates:

And:

Base Repository Methods

Every generated repository extends BaseRepository, so these methods are available immediately:

Backward-compatible aliases:

Generated Service Layer

Use --service to generate Repository, RepositoryInterface, Service, ServiceInterface, DTO, and config in one command:

This creates:

The generated service only forwards pagination and lookup arguments to the repository. Query construction, relationships, sorting, and database access stay in the repository:

Pagination for Million-Row Tables

bigDataPaginate uses Laravel cursor pagination instead of offset pagination. It is intended for large tables and next/previous or infinite-scroll interfaces:

The JSON response contains next_cursor and prev_cursor; pass one of them as the next request's cursor. Cursor pagination does not provide page numbers or a total row count. For best performance, use an indexed, non-null sort column. The repository automatically adds the model primary key as a stable tie-breaker when needed. If you pass a custom $columns selection directly to the repository, include every sorted column and the primary key.

Use chunkById or lazyById for background jobs that must process an entire table; they are not replacements for API/UI pagination.

Model-Aware DTO Generation

When the model defines $fillable, the generator creates matching public readonly DTO fields. Primitive model casts are used for safe PHP types:

The generated UserData exposes name, age, is_active, and settings, and its toArray() method only returns provided fillable fields. Unknown input is discarded while explicitly provided null values are preserved. Fields without a safe primitive cast use mixed. If the model has no $fillable fields, the original generic array DTO is generated unchanged.

Binding Interfaces

You can bind repositories automatically with --bind:

This creates or updates app/Providers/RepositoryServiceProvider.php:

The command also registers App\Providers\RepositoryServiceProvider::class in bootstrap/providers.php for modern Laravel apps, or in config/app.php when that is the available provider registration file.

Configuration

After publishing repository-pattern-config, you can control paths, namespaces, and default generator behavior:

Then inject the interface anywhere:

Custom Repository Methods

Add domain-specific methods to the interface:

Then implement them in the repository:

Testing

Install development dependencies and run the package test suite:

The tests cover:

Package Development

For packages, vendor/ and composer.lock should stay out of the repository. Install dependencies locally when developing:

Before tagging a release, run:

For Packagist, push your repository to GitHub, submit the package, and tag releases with semantic versions:

Security

Please review SECURITY.md before reporting vulnerabilities.

License

The MIT License. See LICENSE for more information.


All versions of repository-pattern with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2|^8.3|^8.4
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^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 gohari/repository-pattern contains the following files

Loading the files please wait ...