Download the PHP package diego-ninja/granite without Composer

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

๐Ÿชจ Granite

Latest Version on Packagist Total Downloads PHP Version License: MIT GitHub last commit wakatime

[Tests]() [Static Analysis]() [Code Style]() [Coveralls]()

A powerful, zero-dependency PHP library for building immutable, serializable objects with validation and mapping capabilities. Perfect for DTOs, Value Objects, API responses, and domain modeling.

๐Ÿชถ Pebble - Lightweight Immutable Snapshots

Pebble is a lightweight alternative to Granite for defensive, immutable snapshots without validation overhead โ€” ideal for caching, Eloquent snapshots, and fast comparisons. Nested arrays, userland objects, and dates are copied so later source mutations cannot change the snapshot.

๐Ÿ“– Read Pebble Documentation


โœจ Features

๐Ÿš€ Quick Start

Installation

Basic Usage

๐Ÿ“– Documentation

Core Concepts

Guides

๐Ÿ“ˆ Performance & Benchmarks

Granite uses a multi-layer fast path system that detects simple DTOs at class-load time and bypasses the full hydration pipeline (reflection, metadata, type conversion) entirely. For objects that qualify, the overhead vs plain PHP constructors is minimal.

Benchmark Results

Measured on PHP 8.5.10 with OPcache CLI enabled, using the median of 7 repetitions with 100,000 operations each:

Scenario ยตs/op Improvement
Plain PHP constructor 0.147 control
Granite::from(array) 0.284 โ€”
Granite::from(JSON) 1.019 6.11x faster
Granite::from(object) 1.000 5.59x faster
Granite::from(Granite) 0.898 7.50x faster
Array-property DTO hydration 0.201 11.69x faster
Validated DTO hydration 4.691 1.96x faster
Cached array() 0.040 22.58x faster
Cached nested array() 0.040 31.56x faster
General array serialization 1.175 1.39x faster
ObjectMapper to plain object 1.869 1.11x faster
ObjectMapper to Granite 1.550 1.14x faster

Improvements compare the same benchmark against the pre-optimization baseline. Full samples and methodology are recorded in the performance optimization plan.

How it works

Granite's performance comes from three layers of optimization:

  1. Capability-specific fast paths (ClassProfile) โ€” Hydration, serialization, and comparison are evaluated independently. Exact array properties can use constructor hydration while still using recursive general serialization.

  2. WeakMap caching โ€” array() and json() results are read before repeating graph analysis and are cached only for deeply immutable graphs. Runtime serialization configuration invalidates cached values.

  3. Compiled metadata โ€” Reflection objects, validation attributes, validators, class date providers, and property transformers are reused across operations.

Classes that need conversion or custom naming use the general pipeline, with cached metadata and early exits for scalar values.

Running the Benchmarks

โš ๏ธ Deprecation Notice

GraniteDTO was already deprecated before v2.0.0, and GraniteVO is deprecated as of v2.0.0, in favor of the unified Granite base class. Both still extend Granite for backward compatibility but will be removed in v3.0.0.

๐Ÿ”ง Requirements

๐Ÿ“ฆ Installation

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license.

๐Ÿ™ Credits

This project is developed and maintained by ๐Ÿฅท Diego Rin in his free time.

If you find this project useful, please consider:


Made with โค๏ธ for the PHP community


All versions of granite with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
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 diego-ninja/granite contains the following files

Loading the files please wait ...