Giter Club home page Giter Club logo

lametric-app-starter's Introduction

LaMetric App Starter

This starter allow you to create LaMetric apps easily. (Indicator App)

How to use it?

Fork this project or create a new repository using this link.

How it works?

Step 1

Declare fields you want to retrieve from your LaMetric App you designed, in file config/fields.php.

e.g.

return [
    [
        'key'  => 'field-1',
        'type' => Field::TEXT_TYPE,
    ],
    [
        'key'  => 'field-2',
        'type' => Field::NUMBER_TYPE,
    ],
    [
        'key'  => 'field-3',
        'type' => Field::SWITCH_TYPE,
    ],
    [
        'key'     => 'field-4',
        'type'    => Field::CHOICES_TYPE,
        'choices' => [
            'iron-man',
            'captain-america',
            'ant-man',
            'thor',
        ]
    ]
];

Fields type association with https://developer.lametric.com :

  • Field::TEXT_TYPE : Text field
  • Field::NUMBER_TYPE : Number
  • Field::SWITCH_TYPE : Switch
  • Field::CHOICES_TYPE : Single choice

The src/Validator.php object will check parameters sent by the app and manage errors.

You can also add default key to a field. If the value is missing from app request, this valus will be use.

e.g.

return [
    [
        'key'     => 'field-1',
        'type'    => Field::TEXT_TYPE,
        'default' => 'hello'
    ],
];

Step 2

Add you logic to the method fetchData() in src/Api.php. Maybe you need to extract data from an API. You can inject any dependencies as needed.

You can also inject credentials like secret api-key : copy config/credentials.php.dist to config/credentials.php and edit content.

/**
 * object $this->client (Guzzle HTTP) is available to make curl requests
 * array $this->credentials contains sensitive data
 * array $parameters (credentials) can contain sensitive data
 */

Step 3

Adapt the method mapData() in src/Api.php to manage frames and data you need.

More information about frames here.

Step 4 & Hosting

You can deploy it everywhere you want. You only need PHP and ext-json (ext-curl if you consume an API).

You only need to configure the docroot of your vhost to the folder public.

Feedback

If you need help, create an issue or contact me on Twitter.

lametric-app-starter's People

Contributors

dependabot[bot] avatar nispeon avatar peter279k avatar pgrimaud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.