Download the PHP package vaibhavpandeyvpz/datum without Composer

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

Datum

Tests PHP Version Code Coverage

A simple Active Record ORM for PHP built on top of vaibhavpandeyvpz/databoss.

Features

Requirements

Installation

Or if you want to install the databoss dependency separately:

Quick Start

Setting Up the Connection

You can set the connection directly or use a connection factory for lazy connection creation using the connect() method:

Direct Connection

Connection Factory (Lazy Loading)

Defining a Model

Basic CRUD Operations

Automatic Timestamps

Datum automatically manages created_at and updated_at timestamps by default. When you save a model:

Disabling Timestamps:

If you want to disable automatic timestamps for a model, set the $timestamps property to false:

Custom Timestamp Column Names:

You can customize the timestamp column names:

Manually Setting Timestamps:

You can still manually set timestamps, and they will be respected:

Using PSR-20 Clock:

Datum uses PSR-20 ClockInterface for timestamp generation, allowing you to inject a custom clock implementation for testing or time manipulation:

For testing, you can use vaibhavpandeyvpz/samay to control time:

UUID Primary Keys

Datum supports UUID (Universally Unique Identifier) primary keys in addition to auto-incrementing integer IDs. When using UUIDs, Datum will automatically generate a UUID v4 before inserting the model into the database.

Setting Up a Model with UUID Primary Key:

Database Schema Example:

For MySQL:

For PostgreSQL:

For SQLite:

Usage:

Key Points:

Attribute Casting

Datum supports automatic type casting for attributes. Define casts in your model's $casts property:

Supported Cast Types:

Example:

Querying

Relationships

Has One

Has Many

Belongs To (Owner)

Belongs To Many (Owners)

Model Events

Datum supports PSR-14 compliant event dispatching, allowing you to hook into model lifecycle events. Events are fired at key points during model operations, giving you the ability to perform actions like logging, validation, or side effects.

Setting Up the Event Dispatcher:

You can set the dispatcher directly or use a factory for lazy dispatcher creation:

Available Events:

Datum fires the following events during model operations:

Event Order:

When saving a new model:

  1. Saving event
  2. Creating event
  3. Database insert
  4. Created event
  5. Saved event

When updating an existing model:

  1. Saving event
  2. Updating event
  3. Database update
  4. Updated event
  5. Saved event

When deleting a model:

  1. Deleting event
  2. Database delete
  3. Deleted event

Listening to Events:

All events implement Psr\EventDispatcher\StoppableEventInterface, allowing you to stop event propagation if needed:

Stopping Event Propagation:

You can stop event propagation to abort an operation:

Complete Example:

Using with Dependency Injection:

Advanced Filtering

Datum supports all databoss filter syntax:

API Reference

Model Static Properties

Model Static Clock Methods

Model Static Event Dispatcher Methods

Model Static Methods

Model Instance Methods

Builder Methods

Relationship Methods

Property Access

Models support magic property access for attributes and relationships:

Examples

Complete Example

Testing

The project includes Docker Compose configuration for running tests:

Tests run against MySQL, PostgreSQL, SQLite, and SQL Server to ensure compatibility across all supported databases.

The test suite includes:

Contributing

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

License

MIT License - see LICENSE file for details.


All versions of datum with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/clock Version ^1.0
psr/event-dispatcher Version ^1.0
vaibhavpandeyvpz/databoss Version ^2.1
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 vaibhavpandeyvpz/datum contains the following files

Loading the files please wait ...