2017 © Pedro Peláez
 

library bind-activerecord

Binds ActiveRecord to ICanBoogie

image

icanboogie/bind-activerecord

Binds ActiveRecord to ICanBoogie

  • Sunday, March 18, 2018
  • by olvlvl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,350 Installations
  • PHP
  • 7 Dependents
  • 2 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

bind-activerecord

Release Code Coverage Downloads, (*1)

The icanboogie/bind-activerecord package binds the icanboogie/activerecord package to ICanBoogie, using its Autoconfig feature. It provides configuration builders for active record connections and models, as well as getters for the connection provider and the model provider., (*2)

<?php
namespace ICanBoogie\Binding\ActiveRecord;

use ICanBoogie\Application;
use ICanBoogie\ActiveRecord\Config;
use ICanBoogie\ActiveRecord\Model;
use ICanBoogie\ActiveRecord\ConnectionProvider;
use ICanBoogie\ActiveRecord\ModelProvider;

/* @var Application $app */

$app = boot();

$config = $app->configs[Config::class];

echo count($config->connections);
echo count($config->models);

$primary_connection = $app->service_for_id('active_record.connection.primary', Connection::class);
# or
$primary_connection = $app->service_for_class(ConnectionProvider::class)->connection_for_id('primary');

$nodes = $app->service_for_class(ModelProvider::class)->model_for_record(Node::class);

Installation

composer require icanboogie/bind-activerecord

Autoconfig

The package provides a configuration builder for ICanBoogie\ActiveRecord\Config., (*3)

The activerecord config fragment

Currently activerecord fragments are used to configure connections and models, which are suitable to create ConnectionCollection and ModelCollection instances., (*4)

The following example demonstrates how to define connections and models. Two connections are defined: primary is a connection to the MySQL server;cache is a connection to a SQLite database. The nodes model is also defined., (*5)

<?php

// config/activerecord.php

use ICanBoogie\ActiveRecord\ConnectionOptions;
use ICanBoogie\ActiveRecord\Model;
use ICanBoogie\ActiveRecord\Schema;
use ICanBoogie\ActiveRecord\SchemaColumn;
use ICanBoogie\ActiveRecord\Config;
use ICanBoogie\ActiveRecord\ConfigBuilder;
use ICanBoogie\ActiveRecord\SchemaBuilder;

return fn(ConfigBuilder $config) => $config
    ->add_connection(
        id: Config::DEFAULT_CONNECTION_ID,
        dsn: 'mysql:dbname=mydatabase',
        username: 'root',
        password: 'root',
        table_name_prefix: 'myprefix',
        time_zone: '+02:00',
    )
    ->add_connection(
        id: 'cache',
        dsn: 'sqlite:' . ICanBoogie\REPOSITORY . 'cache.sqlite'
    )
    ->add_model(
        id: 'nodes',
        activerecord_class: Node::class,
        schema_builder: fn(SchemaBuilder $b) => $b
            ->add_serial('id',primary: true)
            ->add_varchar('title')
    );

Continuous Integration

The project is continuously tested by GitHub actions., (*6)

Tests Static Analysis Code Style, (*7)

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code., (*8)

Contributing

See CONTRIBUTING for details., (*9)

The Versions

18/03 2018

5.0.x-dev

5.0.9999999.9999999-dev https://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

18/03 2018

4.0.x-dev

4.0.9999999.9999999-dev https://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

18/03 2018

dev-master

9999999-dev https://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

18/03 2018

v4.0.0

4.0.0.0 https://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

24/11 2016

3.0.x-dev

3.0.9999999.9999999-dev http://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

06/11 2016

v3.0.0

3.0.0.0 http://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

26/12 2015

v2.3.0

2.3.0.0 http://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

28/02 2015

v0.2.1

0.2.1.0 http://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

23/02 2015

v0.2.0

0.2.0.0 http://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

08/02 2015

v0.1.0

0.1.0.0 http://icanboogie.org/

Binds ActiveRecord to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires