Download the PHP package inz/repository without Composer

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

Build Status Packagist Version Packagist PHP from Packagist GitHub GitHub code size in bytes GitHub repo size

Repository pattern generator

This package helps you get started quickly to use repository pattern in your next, or current, laravel project because after watching those laracon videos (which by the way are A LOT :p) that talks about design patterns and SOLID principals you became all hipped to try and adapt them, at least i'm :D.


Content


Introductory

Using this package will help you spend more time focusing on your application's logic by taking care of generating and implementing a layer that sits between the logic and the database. It generates:

Note: for now, the minimum laravel version this package is tested on is 5.5

Installation

if you using laravel 5.4 and below, you need to add the package's service provider in config/app.php

then, you need to publish the configuration file so the package can do it's work properly:

this will copy the package's configuration file into config folder of the application, more about it in configuration section

Configuration

The configuration file for the package contains a group of settings which can be modified to satisfy your needs, they have a hopefully clear comments that describes their purposes.

Usage

Generating contract & implementation

To generate a full scaffold, you run

Notes

Binding contract to implementation

to bind a contract class to an implementation of a certain model, use the command:

Functionalities

Repository abstract class

In Inz\Base\Abstractions\Repository you can find the implementation of Inz\Base\Interfaces\RepositoryInterface that describes the methods used to access the database.

Properties Why
protected $model; model instance used to query data
protected $attributes; attributes list of the model, also the list of columns of the table, excluding the ones in $excludedColumns.
protected $excludedColumns; to define the columns that will be excluded when the repository object operates on the table, to add other columns to this array just override it in your repository implementation class.

Methods

Here is the list of available methods of the repository class:

Note: Repository class should be implemented the way you desire, so use the interface to define the blueprint for it and implement additional methods or override existing ones in the concrete class.

Method Parameters Return Description
all(); array cols default ['*'] Collection similar to all() of eloquent model
first(); Model instance or null similar to first() of eloquent model
find(); mixed id Model instance or null similar to find() of eloquent model
findWhere(); String column, mixed value & String operator Collection finds all records that match the condition of where clause
findFirstWhere(); String column, mixed value & String operator Model instance or null finds the first record that matches the condition of where clause
paginate(); int count default 10 LengthAwarePaginator instance similar to paginate() of eloquent model
save(); array data = [column => value] boolean creates a new instance based on the passed data and persist it to storage
update(); int id & array data = [column => value] boolean updates a record based on the passed data and persist it to storage, if the record doesn't exist false is returned
delete(); int id boolean similar to delete() of eloquent model
count(); int similar to count() of eloquent model

Soft deleted records

To handle trashed records of the table (if using soft delete trait in the model), use trait Inz\Base\Traits\TrashedOperations in repository implementation class, it contains this set of methods:

Method Parameters Return Description
allTrashed(); array cols default ['*'] Collection returns soft-deleted records only
allWithTrashed(); array cols default ['*'] Collection returns the whole records of the table
firstTrashed(); Model instance or null fetches the first record from trashed ones only
findTrashed(); mixed id Model instance or null fetches a record of the passed id from trashed ones only
findWithTrashed(); mixed id Model instance or null fetches a record of the passed id from the whole table
countTrashed(); int returns the count of trashed records in the table
countWithTrashed() int returns the count of all records in the table
restore(); mixed id boolean restore a soft-deleted record in trashed ones
erase(); mixed id boolean permanently deletes a record from the table

Contribution

Feel free to make any pull request, any contribution is welcomed. If you encountered a problem, use the issues section.


All versions of repository with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.2
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 inz/repository contains the following files

Loading the files please wait ....