PHP code example of openbuildings / jam-resource

1. Go to this page and download the library: Download openbuildings/jam-resource library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

openbuildings / jam-resource example snippets

 php

// Define the users resource
Resource::set('users');
 php


Resource::set('users', array(
	'only' => array(
		'index',
		'show'
	)
));
 php


Resource::set('users', array(
	'except' => array(
		'destroy',
		'edit',
		'update'
	)
));
 php


Resource::set('users', array(
	'with' => array(
		'picture',
		'collection' => array(
			'featured'
		)
	)
));
 php


Resource::set('photos', array(
	'controller' => 'pictures',
	'model' => 'image'
));
 php


Resource::('users', array(
	'path' => 'people'
));
 php


// Jam_Model
$user = Jam::factory('user', 1);

// Jam_Collection
$users = Jam::query('user');

// /users/1
Resource::url($user);

// /users
Resource::url('users');

// /users
Resource::url($users);

// /users/1/edit
Resource::url($user, array('action' => 'edit'));

// /users
Resource::url('users', array('action' => 'create'));