PHPackages                             motty/laravel-common - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. motty/laravel-common

ActiveLibrary[Framework](/categories/framework)

motty/laravel-common
====================

Laravel - Common classes and services

v0.1.1(11y ago)2522MITPHPPHP &gt;=5.5.9

Since Jun 30Pushed 11y agoCompare

[ Source](https://github.com/motty/laravel-common)[ Packagist](https://packagist.org/packages/motty/laravel-common)[ RSS](/packages/motty-laravel-common/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Laravel - Common classes and services
-------------------------------------

[](#laravel---common-classes-and-services)

Tests
-----

[](#tests)

This are a bunch of `classes` / `traits` that try to add all the missed parts from [Laravel 5.1 new testing integration suite](http://laravel.com/docs/5.1/testing) in an attempt to make our testing life even easier

### Configuration

[](#configuration)

#### Environment parameters

[](#environment-parameters)

We will need to setup the following environments parameters in order to make the testing helpers work.

```
FACTORIES_PATH      =   [...]
MIGRATIONS_PATH     =   [...]
MODELS_NAMESPACE    =   [...]

```

We will find the following `Traits` to be used in our `TestCase`:

```
use Motty\Laravel\Common\Testing\Api;
use Motty\Laravel\Common\Testing\CleanDatabase;
use Motty\Laravel\Common\Testing\MigrateDatabase;
use Motty\Laravel\Common\Testing\ResetModelEvents;
use Motty\Laravel\Common\Testing\RelocateFactories;

class ApiTestCase extends TestCase
{
    use Api, CleanDatabase, MigrateDatabase, RelocateFactories, ResetModelEvents;
...
```

##### Traits

[](#traits)

###### Api

[](#api)

This `trait` will provide us with a bunch of methods to help us when testing APIs

```
// Decode as json the response from call and store it on jsonResponse object
getJson()

// Asserts that an object has a specified attributes
assertObjectHasAttributes()

```

###### CleanDatabase

[](#cleandatabase)

Method used to clean the database, this will be a specific method in charge of restart all the autoincrement index, truncate the tables if needed and all the tasks related to prepare the database before each the test case

I was needed to seed the database for each test case independently, however I ran into a problem in where the `autoincrement` value of my tables do not get restarted when `rolling back` or when using a `transaction`

We can use Laravel trait `DatabaseTransactions` to delete all our just saved records after each `test case` however that won't restart the index database's table, which you could need if you need to access any of the elements that you have saved into the database previously.

> Note: This just work at the moment with Postgres database, you could if you whish at a PR for other Database

###### MigrateDatabase

[](#migratedatabase)

Trait used to migrate the database according to our environment parameter MIGRATIONS\_PATH

```
/**
 * @beforeClass
 */
public static function migrateDatabase()
{
    // migrate database according to our environment parameter MIGRATIONS_PATH
    Artisan::call('migrate', ['--path' => env('MIGRATIONS_PATH', 'database/migrations')]);
}
```

###### RelocateFactories

[](#relocatefactories)

Trait used to relocate Factories according to our environment parameter FACTORIES\_PATH, by default Laravel use the factories that are on the path `database/factories` however to override this behaviour and use our own path for the factories is no trivial.

[more info](https://laracasts.com/discuss/channels/laravel/l51-how-to-change-factories-path-when-using-model-factories)

###### ResetModelEvent

[](#resetmodelevent)

Trait used to reset Models' events after each test to trigger eloquent models events when testing

In order to made this `trait` work we'll need to specify our models like so in our `TestCase` class:

```
protected $models = [
    'Contact',
    'User'
];
```

[more info](https://github.com/laravel/framework/issues/1181)

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

4018d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6e40688d47bb7d8701d52b60d424671e4643473e62586369de49168c2a3c799?d=identicon)[motty](/maintainers/motty)

---

Top Contributors

[![zot24](https://avatars.githubusercontent.com/u/678498?v=4)](https://github.com/zot24 "zot24 (11 commits)")

---

Tags

frameworklaravellumencommonclassesservices

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/motty-laravel-common/health.svg)

```
[![Health](https://phpackages.com/badges/motty-laravel-common/health.svg)](https://phpackages.com/packages/motty-laravel-common)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k55.0M619](/packages/laravel-scout)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M131](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
