2017 © Pedro Peláez
 

library artificer

Build dynamic HTML forms with Artificer using JSON.

image

santhoshkorukonda/artificer

Build dynamic HTML forms with Artificer using JSON.

  • Tuesday, April 18, 2017
  • by santhoshkorukonda
  • Repository
  • 0 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Artificer

Build dynamic HTML forms with Artificer using JSON. It is a wrapper on the top of Laravel Collective Html., (*1)

Introduction

Artificer provides a simple API to generate HTML forms by storing its schema in JSON. It caches the generated HTML form for later requests which improves speed in generation and serving forms., (*2)

Prerequisites

  1. requires php >= 7.1
  2. requires laravel/framework >= 5.4
  3. requires laravelcollective/html >= 5.4

Installation

To install this package through composer, run following command in terminal:, (*3)

composer require santhoshkorukonda/artificer, (*4)

Configuration

We need to setup little configuration before we start using it., (*5)

Add our new provider ArtificerServiceProvider to the providers array of config/app.php:, (*6)

<?php

return [
    'providers' => [
        SantoshKorukonda\Artificer\ArtificerServiceProvider::class,
    ],
];

Next, add an alias to aliases array of config/app.php:, (*7)

<?php

return [
    'aliases' => [
        SantoshKorukonda\Artificer\ArtificerFacade::class,
    ],
];

Next, create a cache store for Artificer by adding config to stores array in config/cache.php:, (*8)

<?php

return [
    'stores' => [
        'artificer' => [
            'driver' => 'file',
            'path' => storage_path('artificer/cache'),
        ]
    ],
];

Next, create a filesystem disk for Artificer by adding config to disks array in config/filesystems.php:, (*9)

<?php

return [
    'disks' => [
        'artificer' => [
            'driver' => 'local',
            'root' => storage_path('artificer/views'),
        ],
    ],
];

Generating Forms

A sample form generation code with a controller and sample json text., (*10)

<?php

namespace App\Http\Controllers;

use Artificer;

class FormController extends Controller
{
    /**
     * Build a sample form from the json.
     *
     * @return html
     */
    public function create()
    {
        // Here json is hardcoded as string to explain you how it works,
        // it can even fetched form a database or a remote http call etc.
        // So whatever it might just fetch the string, decode it and send
        // the schema to build the form.
        $schema = json_decode($this->getJson());
        $data = Artificer::build($schema);
        return view("welcome")->with($data);
    }

    /**
     * Define a sample json schema for form generation.
     *
     * @return string
     */
    protected function getJson()
    {
        return '{}';
    }
}

Its that simple to generate a form., (*11)

Understanding form JSON schema

Checkout following documentation on how to build the json schema which is recognized by the Artificer., (*12)

Form schema

Form schema attributes are same as form options of laravelcollective., (*13)

{
    // define attributes for the form with the key "attributes" in json schema.
    "attributes": {
        "route": "route.name",
        "method": "POST",
        "files": true,
        "id": "Enquiry",
        "class": "form"
    },
    "components": {
        ...
    }
}

The Versions

18/04 2017

dev-master

9999999-dev https://github.com/santhoshkorukonda/artificer

Build dynamic HTML forms with Artificer using JSON.

  Sources   Download

MIT

The Requires

 

by Santhosh Korukonda

artificer santosh korukonda laravel package artificer laravel form laravel package laravel form package

18/04 2017

dev-dev

dev-dev https://github.com/santhoshkorukonda/artificer

Build dynamic HTML forms with Artificer using JSON.

  Sources   Download

MIT

The Requires

 

by Santhosh Korukonda

artificer santosh korukonda laravel package artificer laravel form laravel package laravel form package