Download the PHP package ykaej/simple-repository without Composer

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

simple-repository

simple-repository 是一个为laravel5提供的数据库抽象层,目的是为了将应用的数据库操作和核心的业务逻辑分离开,保证controller的精致。

简介

这是一个简易版的 repository 模式

安装

如果你是 laravel5.5 以上,你将不需要在 app.php 当中加载以下配置:

然后运行这个命令来发布配置

使用

首先,创建你的repository类,你可以在命令行中使用如下命令自动生成该类

其中,--model 是可选的,用来指定 repository 中 model 的名称 ,默认情况下,会根据 repository 的名称自动生成 model 名,生成的文件如下:

当然,你也可以手动创建 repository 类,该类必须继承 Ykaej\Repository\Eloquent\BaseRepository ,并实现 model() 方法, 该方法用来指定该repository对应的数据模型。

最后,在你的 controller 中使用 repository

可用方法

Ykaej\Repository\Contracts\RepositoryInterface

简单例子

创建一条记录:

修改记录:

批量修改,默认以id为条件更新,如果没有ID则以第一个字段为条件:

按id查找,可以指定查找字段:

按指定字段查找:

多个条件查找:

永久删除:

增加某字段数量

Criteria

Criteria 是一个让你可以根据具体或者一系列复杂的条件来向你的 repository 发起查询的方式, 你可以将一些可能会重复出现多次的查询条件放到这里,达到复用的目的,将复杂的条件查询从 controller 当中抽离出来。

你的 Criteria 类必须继承 Ykaej\Repository\Criteria\Criteria

创建Criteria

一个简单的例子,简单查 没有隐藏的文章

然后,在你的 controller 里面,你可以调用 repository 的 pushCriteria 方法:

你也可以设置在 post 下全局使用的 criteria ,在 PostRepositoryboot 方法中实现 pushCriteria 方法

最后

以上的思路和代码在阅读了很多大神的代码后产生的,尤其是 这个.


All versions of simple-repository with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
illuminate/support Version ^5.2
illuminate/database Version ^5.2
illuminate/filesystem Version ^5.2
illuminate/console Version ^5.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 ykaej/simple-repository contains the following files

Loading the files please wait ....