Code Monkey home page Code Monkey logo

laravel-ng-artisan-generators's Introduction

Laravel AngularJS Artisan Generators

AngularJS generators for Artisan. Originally created at laravel5-angular-material-starter.

Installation

If you're using the starter project, then it's already pre-installed.

composer require laravelangular/generators

//and then add the provider in config/app.php
LaravelAngular\Generators\LaravelServiceProvider::class,

php artisan vendor:publish

Usage

php artisan ng:page name       #New page inside angular/app/pages/
php artisan ng:component name  #New component inside angular/app/components/
php artisan ng:directive name  #New directive inside angular/directives/
php artisan ng:config name     #New config inside angular/config/
php artisan ng:dialog name     #New custom dialog inside angular/dialogs/
php artisan ng:filter name     #New filter inside angular/filters/
php artisan ng:service name    #New service inside angular/services/

These commands will create new directories and files for AngularJS front-end in new ES6 syntax. If not present, commands will create index files (i.e.: index.components.js) and, if enabled, new created classes will be imported.

Configurations are editable in config\generators.php. See below for details.

Configuration

  • source: name of directories. They make a path to new created files
    • root: name of the directory on where all created files and folders will be put.
    • Other entries indicate directories where files will be put. I.e running php artisan ng:component name will be created three new files for component name with root/components/name/ path. Default is angular/app/components/name/
  • suffix: name and extension appended to file name. I.e.: running php artisan ng:directive name will be created a file named name.directive.js.
    • stylesheet: extension for stylesheets. NOTE: Stylesheets are created for both pages and components
  • tests
    • enable: whether to enable or disable creation of test files
    • source: same as source, but for test files
  • misc.auto_import: enable or disable automatic import in index files.
  • angular_modules: configuration for angular root module and submodules. If index files are created before or manually, these settings will help recognize angular modules for automatic import. If index file is created on first command run, these settings will create angular module for you.
    • root: angular root module.
    • standalone: if a module is defined as standalone (i.e.: angular.module('mymodule', [])) or is part of a root module (angular.module('mymodule')). If set to false, use_prefix, prefix and suffix will be ignored and root module name will be used.
    • prefix and suffix: name of module of the type prefix.suffix; i.e.: app.components.
    • use_prefix: whether to use prefix for module name

Documentation

View Angular Generators documentation

Contributors

Originally created at laravel5-angular-material-starter then moved to a separate package by @m33ch

Notes

  • Do not append the word service, it will be automatically added for you.

laravel-ng-artisan-generators's People

Contributors

ekoeryanto avatar flick36 avatar hackur avatar jadjoubran avatar jadsalhani avatar james-coder avatar m33ch avatar matteomeil avatar vikpe avatar yazfield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-ng-artisan-generators's Issues

Repository setup

  • add travis.yml and setup travis
  • add badges to readme
  • configure styleci
  • installation steps

File names

Hi @m33ch

I was thinking for Version 3 of Laravel angular material starter that maybe we change the generated files' names to:

  • .controller.js
  • .directive.js
  • .dialog.js
  • .definition.js
  • .service.js

What do you think?

And maybe we can export the configuration option to config/generators.php so users can override the default extension (.controller.js to .js if they don't like it).

Let me know what you think and how you want us to divide the tasks
I can help with which ever task you like

Cheers ๐Ÿ˜„

Follow John Papa's style guide

  • ControllerAs vm for features
  • ControllerAs vm for dialogs
  • Named controller function for features
  • Named service function
  • Named filter function
  • Named controller function for dialogs
  • Named controller function for directives
  • Named controller function for directive definitions

ng:component to allow arranging components inside specific directories

Sometimes we end up with a bunch of components, and the list inside app/components/ folder increases and becomes an uncomfortable long list to search them for.
So it would be great to organize them inside their own and respective directories, for instance:

/admin/components/admin/ dashboard/dashboard.component.js
/admin/components/user/ profile/profile.component.js

Just like ng:page allows to do e.g. php artisan ng:page admin/dashboard which creates a page inside another directory e.g. app/pages/admin/dashboard/dashboard.page.html

I modified AngularComponent.php so it will be able to do like so, just reusing code from AngularPage.php -> Heres is the diff

Publish templates?

I was thinking maybe we can publish the templates as well in the resources/generators so that users can have the flexibility of modifying the default template
What do you think?

Laravel 5.4.x?

Is there planned support for Laravel 5.4.x? (Or known incompatibilities?) This package seems to be restricted to 5.3.x right now.

ng:component command error

When I execute artisan ng:component my_component I get this error:

[ErrorException]                                                                                                                                                
  file_put_contents(./tests/angular/app/components/my_component.component.spec.js): fail                                         
  ed to open stream: No such file or directory

This shows up because the subfolders angular/app/components are not created.
I fixed this by creating the folders in Console/Commands/AngularComponent.php:

if (!$this->option('no-spec') && config('generators.tests.enable.components')) {
    //create spec folder
    if (!File::exists($spec_folder)) {
        File::makeDirectory($spec_folder, 0775, true);
    }

    //create spec file (.component.spec.js)
    File::put($spec_folder.'/'.$name.'.component.spec.js', $spec);
}

I'm not sure if this is a bug or I'm missing something that's why I didn't make a pull request.

Update composer.json and tag releases

Hi @m33ch

Would you mind if I change the namespace to make it inline with the repo as well? Let me know

And I'll start tagging the 1.0 release after I add the tests (since this has already been used by many users on the original repo)

Update Readme

  • Get documentation from original repository + add reference to original repo since it's already preloaded
  • Mention Alessandro's valuable contribution

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.