2017 © Pedro Peláez
 

library fields

CRUD Fields API for PHP7

image

back-2-95/fields

CRUD Fields API for PHP7

  • Monday, April 25, 2016
  • by back-2-95
  • Repository
  • 0 Watchers
  • 0 Stars
  • 26 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

back-2-95/fields

Generic Field API for PHP7. This library handles only the metadata about entities and fields related to them., (*1)

Travis CI PHP version, (*2)

Graph, (*3)

TODO

I'll keep this todo list on top until the library is usable., (*4)

  • Validate and force field data structure. Now they are just arrays of anything. (IN PROGRESS)
  • In that structure, try to separate general, form and display related data.
  • Implementation example (own repo) e.g. application which uses fields api, mongodb storage and zf2 classes

API

Create API and set storage:, (*5)

$api = new \BackTo95\Fields\Api();
$storage = new \BackTo95\Fields\Storage\FileStorage('data/entities');
$api->setStorage($storage);

Create EntityConfiguration with fields:, (*6)

$track_configuration = new \BackTo95\Fields\Entity\EntityConfiguration([
    'name' => 'track',
    'description' => 'Track represents musical track made with tracker software',
    'fields' => [
        'title' => [...],
        'description' => [...],
    ],
]);

Store the created EntityConfiguration:, (*7)

$api->storeEntityConfiguration($track_configuration);

Get stored EntityConfiguration by name:, (*8)

$api->getEntityConfiguration('track');

EntityConfiguration data

Example entity: track (as in music), (*9)

[
    'name' => 'track',
    'description' => 'Track represents musical track made with tracker software',
    'fields' => [
        'artist' => [
            'name' => 'artist',
            'form' => [
                'widget' => 'text',
                'filters' => ['trim'],
            ],
            'required' => 1,
        ],
        'title' => [
            'name' => 'title',
            'form' => [
                'widget' => 'text',
            ],
            'required' => 1,
        ],
        'description' => [
            'name' => 'description',
            'form' => [
                'widget' => 'editor',
            ],
        ],
        'cover' => [
            'name' => 'cover',
            'form' => [
                'widget' => 'image',
            ],
        ],
        'genre' => [
            'name' => 'genre',
            'form' => [
                'widget' => 'tags',
                'validators' => [
                    'min' => 1
                ],
            ],
            'multivalue' => 1,
            'required' => 1,
        ],
    ]
],

Notes: widget name can be anything, the implementing library will decide what the widgets are finally. E.g. widget "editor" can be CKeditor, TinyMCE or something else., (*10)

Output

This library should just return entities and their field configurations which can be then used by some other component to store, render, validate etc., (*11)

Rendering

Rendering is not responsibility of this class., (*12)

UI for creating configurations

UI is not part of this library. It should be another library which requires and uses this library., (*13)

Storage

Storing this configuration is not part of this library e.g. https://github.com/back-2-95/fields-mongodb, (*14)

This library provides interface for Storage adapters and file based solution as an example., (*15)

By default this adapter uses path data/entities for storing configurations., (*16)

The Versions

25/04 2016

dev-master

9999999-dev https://github.com/back-2-95/php-crud-fields

CRUD Fields API for PHP7

  Sources   Download

The Requires

 

The Development Requires

by Marko Korhonen

28/03 2016

v0.1-alpha1

0.1.0.0-alpha1 https://github.com/back-2-95/php-crud-fields

CRUD Fields API for PHP7

  Sources   Download

The Requires

 

The Development Requires

by Marko Korhonen

28/03 2016

v0.2

0.2.0.0 https://github.com/back-2-95/php-crud-fields

CRUD Fields API for PHP7

  Sources   Download

The Requires

 

The Development Requires

by Marko Korhonen