generator-ember-laravel

A generator creating ember specific templates in a laravel world

Ember/Laravel Generator

A Yeoman generator for building Ember web apps with a Laravel Backend

This generator was created to be used with the Ember Laravel Starter Kit but, it can be used without it.

simply run npm install generator-ember-laravel

or

Simply, clone this repository and then run 'npm link'.

Important: when you clone the repository, clone it into a folder named "generator-ember-laravel". If you do not, the symlink will not work.

From there you can use these Commands:

yo ember-laravel

scaffolds ember app inside main directory like so:

  • ember/
  • ember/model/
  • ember/views/
  • ember/templates/
  • ember/controllers/
  • ember/routes/
  • app.js
  • routes.js

yo ember-laravel:model modelName attrName2:attrType attrName:relationshipType:relatedModel

generates:

App.Modelname = DS.Model.extend({
    
        
            attrName: DS.attr('string'),
            attrName2: DS.hasMany('relatedModel')
        
    
});

Supported Attributes: string, number, date and boolean

Relationship Support: if you want to include a hasMany or belongsTo relationship, type yo ember-laravel:model modelName attrName:relationshipType:relatedModel

yo ember-laravel:controller controllerName

 
App.ControllerNameController = Ember.ObjectController.extend({
  
});

yo ember-laravel:controller controllerName --array

 
App.ControllerNameController = Ember.ArrayController.extend({
  
});

yo ember-laravel:view viewName

creates

App.ViewNameView = Ember.View.extend({
 
    //classNames: "container", 
    //tagName: 'div' 
  
});

yo ember-laravel:templates templateName

creates

{{!-- file located at ember/templates/templateName.hbs --}}
<h1> templateName Template </h1> 
 

Protip: The command supports subdirectories. So if you type something like yo ember-laravel:template customers/index, it would create a template located in ember/templates/customers/index.hbs

yo ember-laravel:route routeName

generates a route file ember/routes/routeName.js that follows this code structure:

App.RouteNameRoute = Ember.Route.extend({
 
  modelfunction(params) {
      return this.store.find('routeName',params.routeName_id); 
  }
  
});

Note: The file generated will include code that needs to be included in the ember/routes.js file.