PHPackages                             breadam/emberize - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. breadam/emberize

ActiveLibrary[API Development](/categories/api)

breadam/emberize
================

A Laravel package for generating Ember friendly responses

346PHP

Since Jul 13Pushed 11y ago1 watchersCompare

[ Source](https://github.com/breadam/emberize)[ Packagist](https://packagist.org/packages/breadam/emberize)[ RSS](/packages/breadam-emberize/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel 4 response generator for Ember.
=======================================

[](#laravel-4-response-generator-for-ember)

### Emberize in a nutshell

[](#emberize-in-a-nutshell)

```
1. Usage: Emberize::make($model or $collection)
2. Sideload,embed,links
2. (Not Yet)Polymorphic relationships.
3. Public keys(GUID, email, username, etc as id)
4. Change attributes,relationships dynamically(If authorized then include user relationship in json)

```

### Installation

[](#installation)

```
1. Add the following to your composer.json "require" array

    "breadam/emberize": "dev-master"

2. Add the following to your app/config/app.php "providers" array

    "Breadam\Emberize\EmberizeServiceProvider"

3. Update composer

    composer update

4. Publish config file

    php artisan config:publish breadam/emberize

5. Edit app/config/packages/breadam/emberize/config.php to your needs

```

### Quick Example

[](#quick-example)

```
-- Database --

table foos(id,public_key,name,bar_id)

table bars(id,bar_specific_public_key,name)

table buses(id,public_key,name,foo_id)

-- Models --

    class Foo extends Eloquent{

        public function bar(){ return $this->belongsTo("Bar"); }

        public function buses(){ return $this->hasMany("Bus"); }
    }

    class Bar extends Eloquent{
        public function foos(){ return $this->hasMany("Foo"); }
    }

    class Bus extends Eloquent{
        public function foo(){ return $this->belongsTo("Foo"); }
    }

-- app/config/packages/breadam/emberize/config.php --

return array(

	"mode" => null,

    "identifier" => array(
        "key" => "id",
        "value" => "public_key"
    ),

    "resources" => array(

        "foo" => array(
            "fields" => array(
				"name",
				"bar:sideload",
				"buses:"embed"
			)
        ),

        "bar" => array(

            "identifier" => array(
                "value" => "bar_specific_public_key"
            ),

            "fields" => array(
				"name",
				"foos:links"
			)
        ),

        "bus" => array(
            "fields" => array(
				"name",
				"foo:sideload"
			)
        )
    )
)

-- Basic usage  --

    Route::get('/', function(){

        $foo = Foo::find(1);

        return Emberize::make($foo);
    });

-- Update fields. Change will persist until the end of request. --

    Route::get('/', function(){

        $foo = Foo::find(1);

        Emberize::fields(array(
            "foo" => array(
                "exclude" => "bar"
            )
        ));

        return Emberize::make($foo);
    });

-- Update fields.     --

    Route::get('/', function(){

        $foo = Foo::find(1);

        Emberize::fields(array(
           "bar" => array(
               "exclude" => array("foos")
           )
        ));

        if($someCondition){

            return Emberize::make($foo,array(
                "foo" => array(
                    "exclude" => array("buses")
                )
            ));

        }else{
            return Emberize::make($foo,array(
                "foo" => array(
                    "exclude" => array("name")
                ),
                "buses" => array(
                    "exclude" => array("foos")
                )
           );
        }
    });

```

### Configuration

[](#configuration)

#### mode:

[](#mode)

```
Set default mode. If "null", Emberize will prepare only primary keys of relationships

value: null,sideload,embed,link
default: null

```

#### identifier:

[](#identifier)

```
If set, Emberize will use "key" as the primary key name and "value" attribute as primary key value. If not set, Emberize will use $model->getKeyName() and $model->getKey()

value:

	"identifier" => array(
    	"key" => string,
    	"value" => string
	)

default:

	"identifier" => array(
    	"key" => $model->getKeyName(),
    	"value" => $model->getKey()
	)

```

#### resources:

[](#resources)

```
"resources" => array(

	"resource_1" => array(
		"identifier" => array( "key" => "...","value" => "..."),
		"fields" => array(
			"attribute_1",
			"relationship_1:mode"
		)
	),
	"resource_2" => array(...)
)

// Missing

```

#### resolver:

[](#resolver)

```
// Missing

value: A class name implementing "Breadam\Emberize\ResourceNameResolverInterface"

value: "Breadam\Emberize\DefaultResourceNameResolver"

```

### Methods

[](#methods)

#### Emberize::make(\[$model|$collection\],array $fields = null)

[](#emberizemakemodelcollectionarray-fields--null)

```
'$fields': will be merged with fields defined in config and with Emberize::fields(...).

```

#### Emberize::fields(array $fields,$merge = false)

[](#emberizefieldsarray-fieldsmerge--false)

```
'$fields': will be merged with fields defined in config.

usage:

	Emberize::fields(array(
  "model_name_1" => array(
			"include" => array("field_name_1","field_name_2",...)
			"exclude" => array("field_name_1","field_name_2",...)
   ),
		"model_name_2" => array(
			"include" => array("field_name_1","field_name_2",...)
			"exclude" => array("field_name_1","field_name_2",...)
  )
	));

```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3389551?v=4)[breadam](/maintainers/breadam)[@breadam](https://github.com/breadam)

### Embed Badge

![Health badge](/badges/breadam-emberize/health.svg)

```
[![Health](https://phpackages.com/badges/breadam-emberize/health.svg)](https://phpackages.com/packages/breadam-emberize)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
