koalabs/repo
Larablocks Analysis
koalabs/repo works with Laravel 4 (latest release v1.0.0, Sep 22, 2014), which reached end of life: no more fixes, even for security.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 4, past end of life
- No release in the last 12 months (last: Sep 22, 2014)
- 0 downloads a month (needs 10,000)
- 12 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Sep 22, 2014.
- No releases in the last 12 months.
- First released: Sep 22, 2014.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.
| Install | |
|---|---|
composer require koalabs/repo |
|
| Latest Version: | v1.0.0 |
| PHP: | >=5.4.0 |
| Laravel: | 4 |
| License: | MIT |
| Last Updated: | Oct 2, 2014 |
| Links: | GitHub · Packagist |
Laravel Repo
Simple implementation of the Repository Interface for Eloquent with the most basic CRUD methods.
If you find yourself implementing the same default methods over an over again for every new repository class you create, this package could save you some time.
Quick overview
Repo consists of two basic files:
- RepoInterface.php (Interface)
- Repo.php
- CacheableRepo.php
Repo.php
The Repo.php file is just an interface with the basic CRUD methods (Create, Read, Update, Destroy). It will enforce you implement all methods should you choose to use some other kind of Repository in the future.
EloquentRepo.php
The EloquentRepo.php file is an Eloquent implementation of the Repo interface. Keep reading to find out how I intend to use it.
Install
In your application's root directory, open up the composer.json file and add the package to the require section so it looks like this:
"require": {
"koalabs/repo": "dev-master"
},
Open the command line, and in the root ot our application, run the Composer update like this:
php composer.phar update
Now let's add the Repo Service Provider. Open the app/config/app.php file and in the providers array, add the following line:
'Koalabs\Repo\RepoServiceProvider'
Usage
You have at your disposal a simple repository class that handles eloquent entities (models). Every new repository you create will simply be an extension of the EloquenRepository. Here is an example:
use Koalabs\Repo\Repo;
class UserRepository extends Repo {
protected $relations = ['role'];
public function __construct(User $entity)
{
parent::__construct($entity);
}
}
The only thing you have to do for the child repository class is tell the repository which Eloquent model/entity (in this case, User) it should manage. You'll then be able to use default methods for finding, creating, storing, and deleting the specified model. With that you should be good to go, but dive into the package's code for a better grasp at what's happening under the hoods.
Available methods
You'll have these basic CRUD methods at your disposal:
findById($id)findByField($field, $value)all($orderBy)create(array $fields)update($id, array $fields)destroy($id)
Cacheable Repos
There's the added option to use a basic filesystem cache with your repos. Simply extend the CacheableRepo class instead of the Repo and you'll be good to go.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.0 | >=5.4.0 | 4.* | MIT |