dev-master
9999999-dev https://github.com/danidelalin/UndfAngularJsBundleSymfony2 bundle for AngularJs integration
MIT
The Requires
- php >=5.3.1
- symfony/assetic-bundle >=2.1.1
javascript angularjs symfony angular
Symfony2 bundle for AngularJs integration
This bundle provides you with an easy way to integrate AngularJs into your Symfony2 projects., (*1)
It comes with the version 1.0.4 of the AngularJs framework and with a catalogue of angular modules which is very easy to extend with your own modules. Such modules are at this moment split into two main groups:, (*2)
- vendors: Includes a set of widely used modules (ngResource, angular-ui, ...) - undf: Includes a set of modules developed by our developers team.
The bundle also comes with an assetic filter (called 'angularjs'), which provides you with an easy way to include all the modules you want to use in your application (and only those) in one single output file., (*3)
Edit your composer.json and add this line in the "require" object, (*4)
"undf/angularjsbundle" :"dev-master"
Enable the bundle in your AppKernel.php, (*5)
new Undf\AngularJsBundle\UndfAngularJsBundle()
php app/console undf:angularjs:catalogue
The bundle comes with 3 predefined sets of modules:, (*6)
You can add your own module set by editing your config.yml file:, (*7)
undf_angular_js: module_sets: mycustomset: #Use the star character to include all modules from a root module vendors: '*' undf: [uFileUpload, taggable]
You can also extend one of the predefined sets:, (*8)
undf_angular_js: module_sets: novendors: vendors: [ngResource, ui]
php app/console undf:angularjs:create-master-files @MyBundle/Resources/public/js
{% javascripts //...your other javascript files... '@MyBundle/Resources/public/js/default.undfangular.js' //...your angularjs application files... filter="angularjs" output="yourOutputFile.js" %} <script src="{{ asset_url }}" type="text/javascript" ></script> {% endjavascripts %}
The "angularjs" is compatible with any other chained filter you want to apply. Just keep in mind that it should run in the first place, otherwise, the generated content will not go throw the chained filter., (*9)
Once the angularjs assets are dumped, a new angular module will be created at the end of the dumped file; this module will include all modules within your module set as module dependencies. However, this module will be useless untill you add it as a dependency for you angular application. The name of such a module is always build based on the name of the module set:, (*10)
Module set | Module name |
---|---|
default | undfDefaultModule |
novendors | undfNovendorsModule |
... | ... |
var app = angular.module('myangularapp', ['undfDefaultModule']);
undf_angular_js: catalogue: mypackagename: myfirstmodule: description: 'Enter the module description here' files: # Absolute paths to the required files to use this module - @MyBundle/Resources/public/js/mymodule.js mysecondmodule: description: 'Enter the module description here' files: - @MyOtherBundle/Resources/public/othermodule.js
Tip: Run the undf:angularjs:catalogue command to make sure your new modules have been added., (*11)
undf_angular_js: module_sets: mycustomset: vendors: [ngResource, ui] mypackagename: [myfirstmodule, mysecondmodule]
Repeat steps 3, 4 and 5 described in the "Usage" section., (*12)
This is our first approach to the Symfony2-AngularJs integration. The main goal is to get a flexible and easy to extend repository of AngularJs modules, so those modules can be easily reused from one project to another., (*13)
Any ideas or suggestions to improve this bundle will be very welcome., (*14)
Also, don´t hesitate sending a pull request to include your Angular module within the bundle catalogue, which can be done in only 2 steps:, (*15)
1. Add the JS files within the Resources/public/js folder 2. Edit the catalogue file (Resources/config/catalogue.yml).
Make sure that the name you use for the module in the catalogue in exactly the same as in the module declaration in the JS file., (*16)
Create a css filter to handle all related css files., (*17)
Allow twig template files as related files., (*18)
Split vendor modules in separate files., (*19)
Add unit testing, (*20)
Symfony2 bundle for AngularJs integration
MIT
javascript angularjs symfony angular