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

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

networkrailbusinesssystems/common
=================================

Provides common functionality for Network Rail Business Systems Laravel systems

1.5.0(1mo ago)059↓47.2%MITPHPPHP ^8.3

Since Jan 5Pushed 1mo agoCompare

[ Source](https://github.com/Network-Rail-Business-Systems/common)[ Packagist](https://packagist.org/packages/networkrailbusinesssystems/common)[ Docs](https://github.com/Network-Rail-Business-Systems/common)[ RSS](/packages/networkrailbusinesssystems-common/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (23)Versions (10)Used By (0)

[![Composer status](.github/composer.svg)](.github/composer.svg)[![Coverage status](.github/coverage.svg)](.github/coverage.svg)[![Laravel version](.github/laravel.svg)](.github/laravel.svg)[![NPM status](.github/npm.svg)](.github/npm.svg)[![PHP version](.github/php.svg)](.github/php.svg)[![Tests status](.github/tests.svg)](.github/tests.svg)

Common
======

[](#common)

Provides common functionality for Network Rail Business Systems Laravel systems.

What's in the box?
------------------

[](#whats-in-the-box)

- Laravel 12 bootstrapping logic, such as HTTPS forced on for select servers
- CSV helpers for importing and exporting CSVs

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

[](#installation)

### Composer

[](#composer)

You can install this library using Composer:

```
composer require networkrailbusinesssystems/common
```

### Service Provider

[](#service-provider)

The Common service provider will be automatically registered.

If you need to manually load it, you can add the following to your `config/app.php` file:

```
'providers' => [
    // ...
    NetworkRailBusinessSystems\Common\CommonServiceProvider::class,
],
```

### Publish files

[](#publish-files)

The following can be published using `php artisan vendor:publish`:

KeyUsageTargetcommon-configThe Common configuration fileconfig/common.phpcommon-viewsViews provided by this libraryresources/views/vendor/common### Routes

[](#routes)

Add the common routes to your system using the `Route::common()` macro.

Configuration
-------------

[](#configuration)

The `config/common.php` file contains the following options:

KeyUsageTypeDefaultcontrollersWhich controllers to use within common functionsarrayrole, userenumsWhich enums to use within common functionsarraypermissions, rolesforce\_httpsWhether to force HTTPS on regardless of the hostnamestringfalsehomeThe base resource to redirect to from the root directorystring/homemodelsWhich models to use within common functionsarraypermission, role, userpermissionsWhich Permissions to use within common functionsarrayaccess\_admin, manage\_userspoliciesWhich policies to use within common functionsarrayusertemplateWhich template group to use for viewsstringgovukWhere possible a default implementations has been provided for controllers, enums, models, and policies.

You can set or override each implementation by providing the fully qualified name of the new implementation.

### Enums

[](#enums)

You must create enums for Roles and Permissions.

Each must implement the `RoleInterface` and `PermissionInterface` respectively.

A `RoleTrait` and `PermissionTrait` are provided for a standard implementation.

#### Permissions

[](#permissions)

You should add the following Permissions to your enum as a minimum:

- Permission::AccessAdmin
- Permission::ManageUsers

### Models

[](#models)

You must implement your own User model.

An abstract `User` model is provided for you to extend.

Usage
-----

[](#usage)

The components provided by this library should be used in the following ways:

- Called via a provided route
- Called directly
- Extended

### Extending and overriding functionality

[](#extending-and-overriding-functionality)

Before extending any of the components, consider whether the functionality you want to add is system specific, or something you could contribute into common.

The ideal is to keep all common system elements in this library to avoid duplication and reduce maintenance.

Where your functionality is system specific, such as a model relationship, ensure you extend the model from this library.

CSVs
----

[](#csvs)

Use the `Csv` helper to import and export CSVs.

### Import

[](#import)

Utilise the `import` helper to validate the headers and rows of a CSV:

```
$uploadedFile = $formRequest->file('uploaded-file');

$expectedHeaders = ['name'];

$rules = [
    'name' => ['required'],
];

$messages = [
    'name.*' => ['A name is required'],
];

/** @var SimpleExcelReader|array $csv */
$csv = Csv::import($uploadedFile, $expectedHeaders, $rules, $messages);
```

If the validation passes you will receive the `SimpleExcelReader` instance, where you can further process the rows.

If the validation fails you will receive an `array` of error messages.

### Export

[](#export)

Utilise the `export` helper to quickly output a CSV of array entries:

```
$data = [...$someData];

/** @returns BinaryFileResponse */
return Csv::export('my-file', $data);
```

The helper will automatically lowercase and snake-case the filename.

If will also prepend the date, unless you set the `prefixDate` parameter to false.

You may select the disk to be used for the temporary file using the `disk` parameter.

If the provided dataset is empty the CSV will not be created.

Instead, an `HttpResponseException` will be thrown and a message flashed to inform the user.

Ensure that the `rows` passed into `export` can be turned into a flat array per row, otherwise it may fail.

HasFormatters
-------------

[](#hasformatters)

The `HasFormatters` trait is provided for consistent formatting of values in common formats.

MethodTypeOutputformatCount()array|ArrayableString with count before plural or singular termformatCurrency()float|intString in £0.00 formatformatDate()CarbonString in d/m/Y H:i formatformatPrefix()string|intString with prefix added before valueformatSuffix()string|intString with suffix added after valueformatText()stringString with `\n` converted to ``Each method has additional parameters to customise its behaviour.

They also handle "blank" values, returning either `null` or a defined value of your choice.

Help and support
----------------

[](#help-and-support)

You are welcome to raise any issues or questions on GitHub.

If you wish to contribute to this library, raise an issue before submitting a forked pull request.

Licence
-------

[](#licence)

Published under the MIT licence.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.2% 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 ~13 days

Total

7

Last Release

53d ago

Major Versions

0.0.0 → 1.0.02026-01-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17785811?v=4)[Anthony Edmonds](/maintainers/AnthonyEdmonds)[@AnthonyEdmonds](https://github.com/AnthonyEdmonds)

---

Top Contributors

[![AnthonyEdmonds](https://avatars.githubusercontent.com/u/17785811?v=4)](https://github.com/AnthonyEdmonds "AnthonyEdmonds (41 commits)")[![MichaelDono](https://avatars.githubusercontent.com/u/10013030?v=4)](https://github.com/MichaelDono "MichaelDono (30 commits)")[![Tahreem-112](https://avatars.githubusercontent.com/u/176474246?v=4)](https://github.com/Tahreem-112 "Tahreem-112 (9 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

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