Side
Side

Reputation: 1751

Where can I find detailed resource about application structure with Laravel 4 and AngularJS?

I recently started to develop a social network, but the problem is i started to mix my Laravel view with AngularJS what led me to a few problems.

I was searching around the net but was not able to find any info about this.

Could someone help me out with this or give me a hint?

Upvotes: 1

Views: 368

Answers (1)

Jesus Rodriguez
Jesus Rodriguez

Reputation: 12018

I prefer to decouple my Angular.js application from the backend (any backend). You can pick a tool like Linemanjs or Yeoman.

With Lineman (which is the one I use) you develop your app without any backend, in an "isolated way". You can use a fake backend while you are in development mode or even you can have laravel running at port 4567 (just an example) and tell lineman that there is a real backend at 4567 to create a proxy (so you can use your real backend even when your app is in a different folder).

The advantages are many. Decoupled from any backend, so you can switch it to others without any change in Angular. You can take advantage of a pre-configure set of tasks for grunt like Coffeescript, lint, sourcemaps, auto creation of $templateCache, ngmin to avoid minification problems, minification, concatenation... And more if you want.

You also have unit and e2e tests preconfigured...

In short, using this workflow you can create an Angular.js app which plays with any backend and provides you with a lot of tools to create your app easily.

To deploy, both lineman and yeoman creates a "dist" folder with your app itself, just a bunch of static files.

To deploy it with laravel, you just need to drop everything (except the index.html) to the /public folder of laravel. Then convert the index.html to something like home.php in the laravel's /view folder and create a route for it.

We only need to be able to serve the index.html with laravel and that is the best way I found. With that we are able to use html5 mode and make everything work perfect and both part decoupled.

Cheers.

Upvotes: 1

Related Questions