Code Monkey home page Code Monkey logo

php-chef's Introduction

Chef

The Chef Server API is used to provide access to objects on the Chef Server, including nodes, environments, roles, cookbooks (and cookbook versions), and to manage an API client list and the associated RSA public key-pairs.

This is a generic library and has additional support for the Laravel framework.

Installation

Add jenssegers/chef as a requirement to composer.json:

{
    "require": {
        "jenssegers/chef": "dev-master"
    }
}

Update your packages with composer update or install with composer install.

Usage

Create a chef object like this:

// composer
require_once 'vendor/autoload.php';
use Jenssegers\Chef\Chef;

// create chef object
$chef = new Chef($server, $client, $key, $version);

// API request
$response = $chef->api($endpoint, $method, $data);

See http://docs.opscode.com/api_chef_server.html for all available endpoints.

Examples

Get nodes:

$nodes = $chef->get('/nodes');

Create a data bag:

$bag = new stdClass;
$bag->name = "test";

$resp = $chef->post('/data', $bag);

Update a node:

$node = $chef->get('/nodes/webserver1');
$node->attributes->type = "webserver";

$chef->put('/nodes/webserver1', $node);

Delete a data bag:

$chef->delete('/data/test/item');

Laravel

Register the Chef package with Laravel in app/config/app.php, add the following provider:

'Jenssegers\Chef\ChefServiceProvider',

And this alias:

'Chef'            => 'Jenssegers\Chef\Facades\Chef'

Create a copy of the configuration file using Artisan:

php artisan config:publish jenssegers/chef

Edit the created configuration file in app/config/packages/jenssegers/chef/config.php to match your environment:

'server'  = the URL for the Chef Server
'client'  = the name used when authenticating to a Chef Server
'key'     = the location of the file which contains the client key
'version' = the version of the Chef Server API that is being used

php-chef's People

Watchers

 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.