# Combining a PHP Framework with Ember

**URL:** <https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306>\
**Category:** Uncategorized\
**Created:** [July 3, 2015, 2:39pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306 "2015-07-03T14:39:44Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![teejten9](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/teejten9/32/9903_2.png) [@teejten9](https://discuss.emberjs.com/u/teejten9)\
**Post date:** [July 3, 2015, 2:39pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/1 "2015-07-03T14:39:44Z")

</div>

Hell Everyone,

```
This is my first post on this forum. I have read your guy's brilliance for close to a year now. My name is TJ and I have been tinkering with Ember for a couple months off an on. I am now at the point where I only care about Ember and giving up on Angular completely. I can get my homemade PHP API and Laravel to work with Angular reasonably well. But I love Ember so much and I want to use it instead of Angular for my API's.

 I have read different techniques to combine the two and right now the easiest and quickest way to get Ember working with Laravel is by using the app starter kit. Ideally I would like to use Ember-CLI so that opens a whole new set of issues when combining the two. I have a couple build scripts that build ember and place those files into the public/assets folder in Laravel. What I don't get is the rest. I am so confused after this point.

Maybe combining both Ember and Laravel inside the same directory is not what I need at all. Maybe I need to build out my API and other things with Laravel and then install Ember CLI on another directory just using the api calls. This method also confuses me because of CORS. How would I get around the CORS issues with Ember? I'm guessing that I need to start my vagrant server for the Laravel API and the start the Ember server to get them to work together. I also need to use --proxy when using ember server

So, right now I can work with Ember and Laravel but only with the Ember App Kit which I want to use Ember CLI. Could anyone here please help me to get a method or technique that gets Laravel and Ember CLI working. Any feedback would be greatly appreciated.

```

---

<div class="post-metadata">

**Author:** ![kylecoberly](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylecoberly/32/15828_2.png) [@kylecoberly](https://discuss.emberjs.com/u/kylecoberly)\
**Post date:** [July 3, 2015, 4:09pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/2 "2015-07-03T16:09:18Z")

</div>

Congrats on your first post!

What you probably want to do is use Laravel to build out your API, and just use Ember Data to access it. XSS is indeed an issue, but that just means you need to enable CORS on your Laravel app. Try adding this [CORS package](https://github.com/barryvdh/laravel-cors). I noticed that it also handles “pre-flight” requests, which is necessary for Ember Data. In your “allowedOrigins” parameter, set it to “\*” for development, and whatever is hosting your Ember app for production.

---

<div class="post-metadata">

**Author:** ![ToddSmithSalter](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/toddsmithsalter/32/12772_2.png) [@ToddSmithSalter](https://discuss.emberjs.com/u/ToddSmithSalter)\
**Post date:** [July 3, 2015, 5:38pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/3 "2015-07-03T17:38:30Z")

</div>

I highly recommend using Laravel 5.1 with Ember, keeping them in separate repos. Use the CORS package @kylecoberly mentioned. Works a charm.

---

<div class="post-metadata">

**Author:** ![teejten9](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/teejten9/32/9903_2.png) [@teejten9](https://discuss.emberjs.com/u/teejten9)\
**Post date:** [July 3, 2015, 6:34pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/4 "2015-07-03T18:34:51Z")

</div>

Thanks for the quick responses, wow.

Can you explain in detail that last sentence Kyle?

So after I get this package installed what are my next steps? Obviously I have built out the api, do I need to start my vm the laravel is in and run ember server --proxy [http://198.22.1.0](http://198.22.1.0) or whatever. Like I said I am new to getting ember and laravel to work together and I have a ton of questions right now. It looks like I am in for a late night.

---

<div class="post-metadata">

**Author:** ![engwan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/engwan/32/10434_2.png) [@engwan](https://discuss.emberjs.com/u/engwan)\
**Post date:** [July 4, 2015, 3:02am UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/5 "2015-07-04T03:02:44Z")

</div>

You might also find [https://github.com/thephpleague/fractal](https://github.com/thephpleague/fractal) really handy.

It’s like ActiveModelSerializers for Laravel

---

<div class="post-metadata">

**Author:** ![kylecoberly](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylecoberly/32/15828_2.png) [@kylecoberly](https://discuss.emberjs.com/u/kylecoberly)\
**Post date:** [July 4, 2015, 5:48am UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/6 "2015-07-04T05:48:34Z")

</div>

In development, while you’re running the server on your own computer, you just set the allowedOrigins parameter to allow a cross-origin request from any site (the wildcard, \*). That’s because your requests will be coming from localhost:4200- if you set that on a production server, anyone could hit your server from their home computer on that port, so it’s essentially the same as allowing everything. In production, it should be a whitelist of sites that are allowed to query your API, or a wildcard if it’s a public API.

---

<div class="post-metadata">

**Author:** ![teejten9](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/teejten9/32/9903_2.png) [@teejten9](https://discuss.emberjs.com/u/teejten9)\
**Post date:** [July 4, 2015, 7:02pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/7 "2015-07-04T19:02:51Z")

</div>

yep, I found that last night! Are there any example on how to integrate it?

---

<div class="post-metadata">

**Author:** ![teejten9](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/teejten9/32/9903_2.png) [@teejten9](https://discuss.emberjs.com/u/teejten9)\
**Post date:** [July 4, 2015, 7:05pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/8 "2015-07-04T19:05:46Z")

</div>

As an update I have installed the core package last night and have been looking at implementations of fractal or just using my own transformers.

Kyle…Where do I set allowedOrigins parameter? Do you have any info on making a whitelist also?

I am very excited about eventually learning this. It is top priority right now. Thanks again for your help! I can’t say that enough!

---

<div class="post-metadata">

**Author:** ![kylecoberly](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylecoberly/32/15828_2.png) [@kylecoberly](https://discuss.emberjs.com/u/kylecoberly)\
**Post date:** [July 5, 2015, 7:11am UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/9 "2015-07-05T07:11:38Z")

</div>

The details are in the “Configuration” section of that CORS plugin’s Github readme. The whitelist will probably look something like [" [http://www.mydomain.com](http://www.mydomain.com)", “[http://www.myotherdomain.com](http://www.myotherdomain.com)”].

---

<div class="post-metadata">

**Author:** ![broerse](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/broerse/32/9497_2.png) [@broerse](https://discuss.emberjs.com/u/broerse)\
**Post date:** [July 5, 2015, 7:28am UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/10 "2015-07-05T07:28:13Z")

</div>

I don’t know about your use case but we needed just a simple CMS and used a PHP framework called WordPress for this. We just let WordPress templates create json for Ember-Data and let Ember do the rendering.

Example: [http://www.kerstenconstructie.com/](http://www.kerstenconstructie.com/)

---

<div class="post-metadata">

**Author:** ![Hasib\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@Hasib\_Mahmud](https://discuss.emberjs.com/u/Hasib_Mahmud)\
**Post date:** [July 5, 2015, 6:40pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/11 "2015-07-05T18:40:14Z")

</div>

I’ve recently created [StackCombinator](http://stackcombinator.com) using Ember CLI and Laravel. They work great together. I guess you can solve CORS issue using cURL and JSONP like I did in StackCombinator.

But I’ve not used Ember Data. I’ve used only Apache server.

---

<div class="post-metadata">

**Author:** ![kylecoberly](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylecoberly/32/15828_2.png) [@kylecoberly](https://discuss.emberjs.com/u/kylecoberly)\
**Post date:** [July 5, 2015, 7:31pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/12 "2015-07-05T19:31:05Z")

</div>

Just in case there’s any confusion, all Ember Data does is format requests and responses, gives your application a common interface for requesting records, and handles application caching. It does not care what your server or API situation is at all.

---

<div class="post-metadata">

**Author:** ![renq](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/renq/32/11067_2.png) [@renq](https://discuss.emberjs.com/u/renq)\
**Post date:** [July 8, 2015, 5:08pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/13 "2015-07-08T17:08:45Z")

</div>

I’m currently using Symfony2 with FOSUserBundle (user management), FOSOauthBundle (authentication), NelmioCorsBundle (CORS) and FOSRestBundle (REST API) and JMS SerializedBundle (serialization from/to JSON).

I have REST JSON API for my Ember app and something like simple CMS, mainly for testing. In browser I see HTML and standard forms, list, links and tables. I authenticate via login and password. Ember of course sees data in JSON and authenticates via OAuth2. It all depends of “Accept” HTTP header.

I must say that it works quite well. 🙂

---

<div class="post-metadata">

**Author:** ![teejten9](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/teejten9/32/9903_2.png) [@teejten9](https://discuss.emberjs.com/u/teejten9)\
**Post date:** [July 9, 2015, 6:46pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/14 "2015-07-09T18:46:28Z")

</div>

I got the package working! Thanks for all your help and for suggesting it #kylecoberly and #toddsmithsmalter

oh, and are there any other packages you can que me in on?

---

<div class="post-metadata">

**Author:** ![neomerx](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@neomerx](https://discuss.emberjs.com/u/neomerx)\
**Post date:** [August 22, 2015, 10:54pm UTC](https://discuss.emberjs.com/t/combining-a-php-framework-with-ember/8306/15 "2015-08-22T22:54:23Z")

</div>

Full stack for PHP + Ember with JSON API [Ember + PHP with JSON API](http://discuss.emberjs.com/t/ember-php-with-json-api/8655)
