Code Monkey home page Code Monkey logo

laravel-jmespath's Introduction

laravel-jmespath

A Laravel 5 wrapper for use of the jmespath.php library. The jmespath.php library is an implementation of the JMESPath specification.

This package also provides Artisan commands to pre-compile and manage your JMESPath expressions.

Installation

Install through composer

$ composer require libtek/laravel-jmespath

Add Service Provider

In config/app.php, add the service provider to the $providers array:

'providers' => [
    // ...
    Libtek\Jmes\JmesServiceProvider::class,
],

Add alias

In config/app.php, add the facade to the $aliases array:

'aliases' => [
    // ...
    'Jmes' => Libtek\Jmes\Facades\Jmes::class,
],

Publish the configuration file

If you'd like to modify the default configuration values or define expressions to pre-compile, publish the package config file:

php artisan vendor:publish --provider="Libtek\Jmes\JmesServiceProvider"

This will create a jmes.php file in your config directory.

Usage

With facade:

$result = Jmes::search($expression, $data);

Helper function:

$result = jmes($expression, $data);

Artisan commands

Two Artisan commands are available with the package:

jmes:compile

This compiles and caches JMESPath expressions. Expressions can be sourced in multiple ways:

  1. Running the command with no options or arguments will look for expressions in the jmes.php config file:

    php artisan jmes:compile
  2. Passing a single expression to the command:

    php artisan jmes:compile 'foo.*.baz'
  3. Setting the -c or --cli option will prompt for expressions to be added manually:

    php artisan jmes:compile --cli
    
     Please enter a JMESPath expression:
     > foo.*.baz

jmes:clear

This will delete any previously compiled expressions:

php artisan jmes:clear

Pass -h or --help to either command to view its usage.

laravel-jmespath's People

Contributors

libtek avatar

Stargazers

 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.