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.13.2(3d ago)0633↓76.4%MITPHPPHP ^8.3

Since Jan 5Pushed 2d 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 yesterday

READMEChangelog (10)Dependencies (73)Versions (33)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 13 bootstrapping logic, such as HTTPS forced on for select servers
- Exception handling and pages
- 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.

Exceptions
----------

[](#exceptions)

Exception pages are provided for consistent exception handling between systems.

These are registered automatically by the Common Service Provider.

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.

ImprovedHasAttribute
--------------------

[](#improvedhasattribute)

By default, Laravel only checks `$attributes` and `$casts` on a `Model` for attribute existence.

This causes an exception to be thrown when using strict models, even though the attribute name is correct.

Adding `use ImprovedHasAttribute` to a model adds `$fillable` and `$guarded` to the check to avoid this.

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

50

—

FairBetter than 95% of packages

Maintenance100

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 71.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 ~7 days

Total

25

Last Release

2d 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 (99 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)")[![SimRoberts9](https://avatars.githubusercontent.com/u/124249635?v=4)](https://github.com/SimRoberts9 "SimRoberts9 (1 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

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[venturedrake/laravel-crm

A free open source CRM built as a package for laravel projects

43311.1k](/packages/venturedrake-laravel-crm)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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