Download the PHP package salehhashemi/laravel-repository without Composer

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

# Laravel Repository Pattern [![Latest Version on Packagist](https://img.shields.io/packagist/v/salehhashemi/laravel-repository.svg?style=flat-square)](https://packagist.org/packages/salehhashemi/laravel-repository) [![Total Downloads](https://img.shields.io/packagist/dt/salehhashemi/laravel-repository.svg?style=flat-square)](https://packagist.org/packages/salehhashemi/laravel-repository) [![GitHub Actions](https://img.shields.io/github/actions/workflow/status/salehhashemi1992/laravel-repository/static-analysis.yml?branch=main&label=static-analysis)](https://github.com/salehhashemi1992/laravel-repository/actions/workflows/static-analysis.yml) [![GitHub Actions](https://img.shields.io/github/actions/workflow/status/salehhashemi1992/laravel-repository/run-tests.yml?branch=main&label=run-tests)](https://github.com/salehhashemi1992/laravel-repository/actions/workflows/run-tests.yml) [![codecov](https://codecov.io/gh/salehhashemi1992/laravel-repository/graph/badge.svg?token=niiiz6l2tJ)](https://codecov.io/gh/salehhashemi1992/laravel-repository) [![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://phpstan.org/)

This Laravel package simplifies and streamlines data access by implementing the repository pattern. It provides a powerful abstraction layer for your database interactions, enhanced with flexible filtering, searching, and criteria-based querying.

Features

Installation

To install the package, you can run the following command:

Development Tools

The package includes a helpful command to speed up your development workflow:

Usage Example:

or

Example Usage

Practical example of how to use this package to manage and interact with a Post model.

It includes examples of a custom repository, filter, criteria, and controller usage.

Post Repository

The PostRepository class extends BaseEloquentRepository and demonstrates the use of the package's features for a Post model.

Post Repository Interface

The PostRepositoryInterface defines the contract for our repository, ensuring consistency and clarity in method signatures.

Post Filter

PostFilter demonstrates how to apply custom filters to the Post model, enhancing query flexibility.

Featured Post Criteria

The FeaturedPostCriteria is an example of defining criteria for filtering, here focusing on featured posts.

Binding Interface to Implementation

It is crucial to bind the repository interface to its concrete implementation. This enables Laravel service container to automatically resolve and inject the appropriate repository instance wherever it's needed.

  1. Create a Service Provider

  2. Bind in the Service Provider

  3. Register the Service Provider: Add your RepositoryServiceProvider to the providers array in config/app.php.

Repository Usage in controller

This example shows how to use the PostRepository within a controller, integrating it seamlessly into a Laravel application workflow.

Available Methods

This package offers several methods:

findOne

Fetches a single model instance by primary key, or the first model matching applied criteria and relations.

findOneOrFail

Similar to findOne, but throws a ModelNotFoundException if no result is found.

findAll

Retrieves a collection of all models matching the applied criteria, relations, and specified options.

findList

Gets a collection of model values keyed by a specified field, useful for dropdown lists or similar displays.

paginate

Returns a paginated collection of models based on applied criteria, relations, and specified page size.

addCriteria

Adds a new criteria instance to the repository for query filtering.

orderBy

Specifies ordering for the query results based on field and direction.

lockForUpdate

Applies a "lock for update" clause to the query for handling concurrent database access.

sharedLock

Applies a shared lock to the query, preventing modifications of selected rows.

Configuration

To publish the config file, run the following command:

After publishing, make sure to clear the config cache to apply your changes:

Then, you can adjust the pagination limit in the config/repository.php

Exceptions

Docker Setup

This project uses Docker for local development and testing. Make sure you have Docker and Docker Compose installed on your system before proceeding.

Build the Docker images

Start the services

To access the PHP container, you can use:

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-repository with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version 9.*|10.*|11.*
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 salehhashemi/laravel-repository contains the following files

Loading the files please wait ....