Download the PHP package networkrailbusinesssystems/common without Composer

On this page you can find all versions of the php package networkrailbusinesssystems/common. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package common

Common

Provides common functionality for Network Rail Business Systems Laravel systems.

What's in the box?

Installation

Composer

You can install this library using Composer:

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:

Publish files

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

Key Usage Target
common-config The Common configuration file config/common.php
common-views Views provided by this library resources/views/vendor/common

Routes

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

Configuration

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

Key Usage Type Default
controllers Which controllers to use within common functions array role, user
enums Which enums to use within common functions array permissions, roles
force_https Whether to force HTTPS on regardless of the hostname string false
home The base resource to redirect to from the root directory string /home
models Which models to use within common functions array permission, role, user
permissions Which Permissions to use within common functions array access_admin, manage_users
policies Which policies to use within common functions array user
template Which template group to use for views string govuk

Where 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

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

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

Models

You must implement your own User model.

An abstract User model is provided for you to extend.

Usage

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

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

Use the Csv helper to import and export CSVs.

Import

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

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

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

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

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

Method Type Output
formatCount() array|Arrayable String with count before plural or singular term
formatCurrency() float|int String in £0.00 format
formatDate() Carbon String in d/m/Y H:i format
formatPrefix() string|int String with prefix added before value
formatSuffix() string|int String with suffix added after value
formatText() string String with \n converted to <br/>

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

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

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

Published under the MIT licence.


All versions of common with dependencies

PHP Build Version
Package Version
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package networkrailbusinesssystems/common contains the following files

Loading the files please wait ...