Download the PHP package uptoolkit/laravel-repository without Composer

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

Blok Repository

Scrutinizer Code Quality Build Status Packagist Packagist

An opiniated way to handle business logic with the Repository pattern.

This package tends to give you an opiniated structure to handle your business logic inside one repository folder instead of duplicating your code in Controllers, Seeders etc.

It comes with handy helpers to let you use this repository inside your controller, api controller or graphql mutation without the need to redefine the wheel everytimes.

Installation

Install via composer

Usage

Blok repository is a Laravel package that will give extra functionnalities to your model and control.

Create a repository class

It will create a Repository class inside /app/Repositories/UserRepository :

Without any configuration, it will handle the basic CRUD operations :

Off course, you can override any of these methods and create your own inside this Repository Class

How to use it inside your controller ?

Blok/Repository comes with a very handy and common ApiController structure. To use is you can do :

``

It will create an ApiController inside App/Http/Controllers/Api :

`

This controller will handle directly the CRUD logic of your repository for more infos see AbstractApiController

How to use it in Graphql ?

Blok/Repository comes with a very handy and common Graphql Mutation structure. It assumes that you use https://lighthouse-php.com/ to handle GraphQL inside Laravel.

To use is you can do :

``

It will create a graphql mutation inside App/Graphql/Mutations :

`

This controller will handle directly the CRUD logic mutation for Create, Update and Delete.

Adding a business logic with a Criteria class

Off course, any methods of the AbstractClass can be overriden but sometimes you just need to add somewhere else your own query logic to reuse it. For that we implemented a usefull patern that will help to keep your query logic in a separated class reusable anywhere.

Let's give a simple exemple for the get all methods => you want to get only public users.

Create a Criteria

This will create a class inside /app/Repositories/Criterias/OnlyPublicCriteria

Use it inside your Repository

In your UserRepository, you can add and handle your criteria like that :

It will apply the condition of where visibility=public automatically to the $userRepository->all() method.

Use it inside your Controller

In your ControllerClass, you can inject this param like that :

It will have the same behavior but at the Controller level. Off course, you are free to add your variables logic when you initiate the criteria (for exemple here I push the type public for the demo).

Putting this logic inside a Criteria, will help you to queue your query condition and reuse it in different Repository.

Criterias available by default:

You have criterias helpers available in the namespace Blok\Repository\Criterias.

They each contain an argument containing your filters, here are more explanations for some of them :

WhereCriteria:

This criteria is used to filter the data coming from the source model. For the syntax, separate the elements with a space, you can use all the classical operators except BETWEEN which is not implemented yet. You can also use AND and OR with && and ||.

Example:

WhereHasCriteria:

This criteria works like WhereCriteria with the difference that it is there to filter elements of the models related to the source model. For the syntax it's the same as WhereCriteria but you have to put the relation for which the filters are applied followed by a "->" (without space) at the beginning of the query and after each &&. You can use the || but it will be applied to the filtered table (selected with "relationshipName->".

Example:

Security

If you discover any security related issues, please email me instead of using the issue tracker.

Credits

This package is bootstrapped with the help of blok/laravel-package-generator.


All versions of laravel-repository with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/support Version >5.5
blok/utils Version *
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 uptoolkit/laravel-repository contains the following files

Loading the files please wait ....