Download the PHP package aichadigital/lara100 without Composer

On this page you can find all versions of the php package aichadigital/lara100. 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 lara100

Lara100 - Base-100 Cast for Laravel

Tests Code Style PHPStan Latest Version

A Laravel package that provides a custom Eloquent cast for handling monetary/decimal values by storing them as integers (cents) in the database while working with decimals in your PHP code, eliminating floating-point precision errors.

Why Lara100?

Floating-point arithmetic in PHP (and most programming languages) can lead to precision errors:

This is particularly problematic when dealing with:

Lara100 solves this by storing values as integers (cents) in the database, while letting you work with familiar decimal values in your code.

Installation

You can install the package via Composer:

Configuration (Optional)

You can optionally publish the configuration file:

This will create a config/lara100.php file where you can configure:

Alternatively, you can set these via environment variables in your .env:

Requirements

Usage

Basic Usage (Cast)

Apply the Base100 cast to your model attributes:

Now you can work with decimals in your application while storing integers in the database:

Advanced Usage (Trait)

For convenience, you can use the HasBase100 trait to apply the cast to multiple attributes at once:

The trait automatically applies the Base100 cast to all specified attributes.

How It Works

Database → Application (GET)

Application → Database (SET)

Rounding Behavior

By default, the cast uses Round Half Up (PHP_ROUND_HALF_UP):

This is the standard rounding mode used in Spain, the EU, and most countries.

Configuring Rounding Mode

You can configure the rounding mode globally via config or per-attribute:

Global configuration (affects all casts):

Per-attribute override (in your model):

Available Rounding Modes

Mode Constant Behavior Use Case
Half Up PHP_ROUND_HALF_UP (1) 0.555→0.56, 0.545→0.55 Spain/EU standard
Half Even PHP_ROUND_HALF_EVEN (3) 0.555→0.56, 0.545→0.54 Accounting (Banker's)
Half Down PHP_ROUND_HALF_DOWN (2) 0.555→0.55, 0.545→0.54 Conservative rounding
Half Odd PHP_ROUND_HALF_ODD (4) 0.555→0.55, 0.545→0.55 Specialized cases

BCMath Support

For maximum precision with very large amounts, enable BCMath:

Or per-attribute:

Note: Requires the bcmath PHP extension to be installed.

Examples

Working with Monetary Values

Performing Calculations

Handling Edge Cases

Database Schema

Your database columns should be defined as INTEGER (to store cents):

Why INTEGER instead of DECIMAL?

Comparison with Alternatives

Solution DB Column Type PHP Value Type Precision Package Size
Lara100 INTEGER (cents) float (19.99) ✅ Perfect Lightweight cast
moneyphp/money INTEGER (cents) Money object ✅ Perfect Full-featured library
brick/money INTEGER (cents) Money object ✅ Perfect Full-featured library
Native DECIMAL DECIMAL(10,2) float (19.99) ⚠️ Precision issues No package needed

Key Differences:

Choose Lara100 when:

Consider alternatives when:

Testing

The package includes comprehensive tests for both the cast and trait:

Run tests with coverage:

Run tests in parallel:

Code Quality

Run PHPStan static analysis:

Run Laravel Pint code formatter:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Security Vulnerabilities

If you discover a security vulnerability, please send an e-mail to Abdelkarim Mateos Sanchez via [email protected].

Credits

License

The MIT License (MIT). Please see License File for more information.

About AichaDigital

AichaDigital is a ITt company focused on IT services.


All versions of lara100 with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3|^8.4
illuminate/contracts Version ^12.0||^13.0
illuminate/database Version ^12.0||^13.0
spatie/laravel-package-tools Version ^1.16
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 aichadigital/lara100 contains the following files

Loading the files please wait ...