Download the PHP package blackcube/yii-bridge-model without Composer

On this page you can find all versions of the php package blackcube/yii-bridge-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 yii-bridge-model

Blackcube Yii Bridge Model

⚠️ Blackcube Warning

This is not auto-hydration. It's a declared, typed, scenario-filtered bridge between FormModel and ActiveRecord.

You put #[Bridge] on what transfers in FormModel. You control the direction, the format, the scope. Nothing moves without your say-so.

Bidirectional data bridge between FormModel and ActiveRecord for Yii framework.

Packagist Version

Installation

Why Bridge?

Approach Problem
Manual mapping Boilerplate hell, copy-paste errors
Auto-hydration Breaks on type mismatch, no control
Bridge None of the above

You declare mappings with attributes. Bridge handles the rest.

Type conversion is automatic. DateTimeImmutablestring just works.

Scenarios filter what transfers. Edit form ≠ Create form ≠ API form.

Elastic properties are transparent. Dynamic JSON Schema fields work like regular properties.

How It Works

The Bridge Attribute

Data Flow

Quick Start

1. Create your ActiveRecord

2. Create your FormModel

Usage

Load from ActiveRecord

Save to ActiveRecord

Scenarios

Control which fields are active for validation and transfer:

Date Conversion

DateTimeImmutablestring conversion is automatic when you specify a format:

Type Override

When reflection can't detect the type (mixed, inherited, etc.):

Elastic Integration

Bridge works transparently with elastic dynamic properties.

AR with Elastic

FormModel with Elastic

Elastic properties are auto-discovered from the JSON Schema:

Elastic Constants

Constant Effect
ALL_ELASTIC_ATTRIBUTES Include all elastic fields in scenario
NO_ELASTIC_ATTRIBUTES Exclude all elastic fields from scenario

Bridge Resolution

Bridge auto-detects target accessors in this order:

Source Target Detection Order
Property $name setName()getName()/isName()$name
Getter getName() setName()$name
Setter setName() getName()/isName()$name

Explicit attributes always win:

API Reference

BridgeFormModel

Method Description
createFromModel($model) Factory: create and populate from AR
initFromModel($model) Populate from AR
populateModel($model) Transfer to AR (filtered by scenario)
load($data, $scope) Hydrate from array (POST data)
validate() Validate with filtered rules
setScenario($scenario) Set active scenario
getScenario() Get active scenario
getProperties() Get all Bridge components
getRules() Get rules filtered by scenario

Bridge Attribute

Parameter Type Description
name ?string Canonical name (for fusion)
type ?string Override detected type
format ?string Date format for conversion
property ?string Explicit target property
getter ?string Explicit target getter
setter ?string Explicit target setter

Let's be honest

No magic

Bridge doesn't guess. If you don't put #[Bridge], the property is ignored.

One AR per FormModel (usually)

Multi-AR forms are possible (call initFromModel() multiple times) but think twice. Complex forms often mean complex problems.

Elastic requires ElasticHydrator

Yii's default Hydrator doesn't handle elastics. Bridge includes ElasticHydrator that does.

Rules

  1. Always use #[Bridge] — unmarked properties don't transfer
  2. Specify format for dates — or get "Y-m-d H:i:s" default
  3. Use scenarios — don't transfer everything everywhere
  4. Always add rules — Bridge doesn't transfer Form -> AR if property has no validation rules
  5. Validate before populate — Bridge doesn't validate, it transfers

License

BSD-3-Clause. See LICENSE.md.

Author

Philippe Gaultier [email protected]


All versions of yii-bridge-model with dependencies

PHP Build Version
Package Version
Requires ext-intl Version *
yiisoft/active-record Version ^1.0
yiisoft/db Version ^2.0
yiisoft/form-model Version ^1.1
yiisoft/hydrator Version ^1.6
blackcube/active-record Version ^1.0
php Version ^8.1
blackcube/injector Version ^1.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 blackcube/yii-bridge-model contains the following files

Loading the files please wait ...