PHPackages                             trevormh/laravel-startup-helper - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. trevormh/laravel-startup-helper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

trevormh/laravel-startup-helper
===============================

Provides Laravel with additional features to help during startup, such as dynamic validation messages and data sharing between middleware and controllers

01PHP

Since Jul 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/trevormh/laravel-startup-helper)[ Packagist](https://packagist.org/packages/trevormh/laravel-startup-helper)[ RSS](/packages/trevormh-laravel-startup-helper/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Startup Helper
======================

[](#laravel-startup-helper)

This package helps to reduce repeated tasks during the startup of your laravel app all the way through validation by easily allowing data from your middleware and service providers to be shared with your controllers via a content store. Validation messages can also be dynamically created in your custom validators.

Example usecases
----------------

[](#example-usecases)

- Accessing data from middleware in controllers - Example: A vendor may use multiple API keys for different accounts, and each account number is required for processing in the controllers. The authentication process in middleware involves retrieving the account from the database. The controller will have to repeat the same process of querying the account. This package allows the account data to be shared between the middleware and your controllers so that the same query will not have to be repeated again.
- Dynamic validation messages for custom validators - A custom validator can only have a one error message. If a parameter requires multiple conditions to be validated against, a custom validator would have to be created for each validation condition in order to have accurate validation error messages. This package wllows for setting custom error messages within your custom validators.

Installation
------------

[](#installation)

`composer require trevormh/laravel-startup-helper`

General Usage
-------------

[](#general-usage)

First import the package into any php file with:

```
use trevormh\LaravelStartupHelper\StartupFactory;

```

To access the instance:

```
$helper = StartupFactory::resolve();

```

To add content to the store pass an associative array.

```
$helper->addContent([
    'id' => $id,
    'product' => $product
]);

```

To retrieve from the store you can either pass in a single parameter, or no parameters at all to retrieve the entire store.

```
// retrieve a single property
$id = $helper->get('id');

// retrieve all content
$store = $helper->get();

```

Custom Validation Messages
--------------------------

[](#custom-validation-messages)

If you have custom validators you can create dynamic validation messages from within the validator. To do this in your controller create a validator and pass it to the startup helper

```
$validator = Validator::make($request->all(),[
    'id' => 'integer|SomeCustomValidator'
]);
$helper->addValidator($validator);

```

Next in the custom validator, `SomeCustomValidator`, you can add custom error messages to be passed to the laravel validator

```
Validator::extend('SomeCustomValidator', function($attribute, $value $parameters) {
    $helper = StartupFactory::resolve();

    $someOtherValue = Model::find('id',$value);

    if ($value !== $someOtherValue->fieldName) {
        $helper->addErrorMessage("id.some_custom_validator", "The id " . $value . " has failed to validate");
        return false;
    }
    // also add the query we just ran
    $helper->addContent['someOtherValue' => $someOtherValue]);
    return true;
});

```

Back in your controller where you called the custom validator from, you can continue validation as you normally would and if there is a validation failure, your custom error message will be set without any additional configuration

```
if ($validator->fails()) {
    $errors = $validator->errors(); // this will contain the error message set in `SomeCustomValidator`
    return $errors;
}

```

You can also retrieve the data from the query that was executed in `SomeCustomValidator`

```
    $someOtherValue = $helper->get('someOtherValue');

```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b2c1fd27bbe42304fdc922c96e2fc0b2c26e4fce593c4c863da50033736ad6f?d=identicon)[trevormh](/maintainers/trevormh)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/trevormh-laravel-startup-helper/health.svg)

```
[![Health](https://phpackages.com/badges/trevormh-laravel-startup-helper/health.svg)](https://phpackages.com/packages/trevormh-laravel-startup-helper)
```

###  Alternatives

[phabel/phabel

Write and deploy modern PHP 8 code, today.

24560.4k12](/packages/phabel-phabel)[typo3/cms-setup

TYPO3 CMS Setup - Allows users to edit a limited set of options for their user profile, including preferred language, their name and email address.

178.5M103](/packages/typo3-cms-setup)[pfefferle/wordpress-activitypub

The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.

5671.4k1](/packages/pfefferle-wordpress-activitypub)

PHPackages © 2026

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