moszkva / angie by Moszkva

Laravel Angular routing manager. Generates angular routing rules and services from serverside routing rules.
35
2
1
Package Data
Maintainer Username: Moszkva
Maintainer Contact: szecsi44@freemail.hu (Gabor Szecsi (Moszkva))
Package Create Date: 2014-03-17
Package Last Update: 2014-03-29
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:19:04
Package Statistics
Total Downloads: 35
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Angie

Laravel-Angular routing manager. Generates angular routing rules from serverside routing rules and services.

https://packagist.org/packages/moszkva/angie

#Features#

  • Generates angular routing rules from serverside routing rules
  • Generates angular services for basic data transfer.
  • Namespace resolving in controller's name.

##Installation##

Installation via composer

{
   "require-dev": {
        "moszkva/angie": "dev-master"
   }
}

##Usage##

After installation you must register AngieServiceProvider in your config/app.php:


'providers' => array(....,
                     ....,
                     'Moszkva\Angie\AngieServiceProvider'),
'aliases' => array(.....,
                   .....,
                    'Angie'	=> 'Moszkva\Angie\Facades\Angie'));

and you must register routing rules for angie:


// Angie BEGIN

Route::get('angie/get/routing', function()
{
	return Angie::renderRouterProviderStatment('<YourAppName>', '/angie/test');
});

Route::get('angie/get/services', function()
{
	return Angie::renderServices('<YourAppName>');
});


// Angie END


and you must place these in your index.html after each other angular scripts:

<!--Angie BEGIN-->
<script src="angie/get/routing"></script>
<script src="angie/get/services"></script>
<!--Angie END-->

##How works the angie?##

  • Generates angular routeprovider statment. Above example:
<YourAppName>.config(['$routeProvider',
    function($routeProvider) {
            $routeProvider
			.when("/angie/test",{"controller":"AngieTestController","templateUrl":"angie/test"})
			.when("/angie/test/create",{"controller":"AngieTestController","templateUrl":"angie/test/create"})
			.when("/angie/test/:test",{"controller":"AngieTestController","templateUrl":"angie/test/' + $routeParams.test + '"})
			.when("/angie/test/:test/edit",{"controller":"AngieTestController","templateUrl":"angie/test/' + $routeParams.test + '/edit"})
			.when("//",{"controller":"TestController","templateUrl":"/"})
			.otherwise({"redirectTo":"/angie/test"})}]);

  • Generates angular services for basic data transfer:
var <YourAppName>Services= angular.module('<YourAppName>Services', ['ngResource']);

AngieTestControllerService.insert(properties);		
AngieTestControllerService.update(properties);
AngieTestControllerService.delete(id);
AngieTestControllerService.show(id);
AngieTestControllerService.list(id, params); // params is optional.

Very important constraint for valid service generation:

  • Laravel routing rules by controller must be unique. Example:

Valid configuration (AnotherAngieTestController is subclass of AngieTestController):

Route::resource('angie/test', 'AngieTestController');
Route::resource('angie/test2', 'AnotherAngieTestController');

Invalid configuration:

Route::resource('angie/test', 'AngieTestController');
Route::resource('angie/test2', 'AngieTestController');

Namespace resolving:

Laravel route rule:

	Route::resource('/test', 'Test\Angie\TestController')
	
Controller name in generated routprovider statement:

	TestAngieTestController
	
Service name in generated service statement:

	TestAngieTestControllerService