Download the PHP package basanta/array-model without Composer

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

Array Model

basanta/array-model is a lightweight Laravel-friendly library that lets you treat in-memory arrays like model records with collection-style querying and bulk operations.

It is useful when you want model-like behavior without a database layer.

Features

Requirements

Installation

Install via Composer:

Quick Start

Create a model class by extending Basanta\ArrayModel\ArrayModel:

Create records:

Query records:

Get all records as array:

Relationships and Lazy Loading

Define relationships directly on your array model:

Lazy load on first access:

Bulk lazy load for all records:

How It Works

Each model subclass gets its own in-memory Collection instance (stored statically per class).
All static calls are proxied to that collection, so you can use collection-driven patterns while working with model objects.

API Reference

ArrayModel

static factory()

Returns the in-memory Basanta\ArrayModel\Collection for the calling model class.

static create(array $attributes): static

Creates a new model instance and stores it in the class collection.

static update(array $where, array $attributes): bool

Finds matching items using where($where) and updates them.

static array(): array

Returns the full model store as a plain array.

static load(...$relationship): Basanta\ArrayModel\Collection

Lazy-loads one or more relationships for all records in the model store.
Accepts variadic relation names or a single array of relation names.

toArray(): array

Converts the current model object to a plain array.

Relationship helpers

Magic attributes

Collection

Extends Illuminate\Support\Collection and adds model-focused behavior.

where($key, $operator = null, $value = null): static

Supports:

whereMany(array $conditions): static

Supports two condition formats:

  1. Associative format:

  2. List format (each rule can be [key, value] or [key, operator, value]):

Supported operators:

Invalid formats or unsupported operators throw exceptions.

update(array $attributes): bool

Bulk-updates all items in the current filtered collection.

delete(): bool

Removes all items in the current filtered collection from the model store.

Usage Patterns

Filter and bulk update

Filter and delete

Use advanced operators

Behavior Notes

Error Handling

The package throws exceptions for:

Use try/catch around dynamic filter construction if conditions may be user-defined.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes with tests (if applicable)
  4. Open a pull request

License

No explicit license is currently declared in composer.json.
If you plan to use this package in production or redistribute it, confirm licensing with the maintainer first.


All versions of array-model with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version >=10.0
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 basanta/array-model contains the following files

Loading the files please wait ...