SlideShare uma empresa Scribd logo
1 de 28
Javascript Laravel's friend
Introduction
● Bart (@denbatte)
● Teacher
● PHP/Laravel enthousiast
● Slides will be available on slideshare
Objectives
● Creating the best game ever!
● Exploring Laravel by doing the previous.
● Learning how Javascript integrates with Laravel
– Not using JS Frameworks (Angular) for now!
Preparing Laravel with composer
composer.json
"require": {
"laravel/framework": "4.1.*",
"laracasts/utilities": "1.0",
// Development packages
"way/generators": "2.*",
"barryvdh/laravel-ide-helper": "1.*",
"fzaninotto/faker": "v1.3.0",
"fedeisas/laravel-js-routes": "1.3"
}
Do not forget to add the serviceProviders at app/config/app.php
The game - Login
The game - Dashboard
Road map
● Preparing Laravel
– Database and models
– Routes and controllers
● Adding Jquery and custom scripts using blade
● Giving PHP data to Javascript
– The easy way
– The even more easy “Jeffrey” way
● Making a ajax call to a controller
– Using named routes
– Named routes as import
Preparing the database
● Migration files for users/score table
● Seeding with faker
terminal
user@device: php artisan generate:migration create_<name>_table
user@device: php artisan generate:seed
user@device: php artisan migrate –-seed
Do not forget to add database settings at app/config/database.php
Preparing the database
● Migration files for users/score table
● Seeding with faker
terminal
user@device: php artisan migrate –-seed
Migration file Seed file
Generating database models
● A model will make Eloquent understand your data.
– User.php is already there
– Adding Score.php model
terminal
user@device: php artisan generate:model Score
Preparing routes
app/routes.php
// Game: sessions resource – login and logout
Route::resource('sessions', 'SessionsController');
Route::get('/', 'sessionsController@create');
Route::get('login', 'sessionsController@create');
Route::get('logout', 'sessionsController@destroy');
// Actual game view
Route::get('game', "ScoreController@highscore")->before("auth");
// Score: Ajax route retrieving high score
Route::post( '/score/{level}', array(
'as' => 'score.index',
'uses' => 'ScoreController@index'
) );
// Score: Ajax route updating player score
Route::post( '/score/update', array(
'as' => 'score.update',
'uses' => 'ScoreController@update'
) );
Generating controllers
terminal
user@device: php artisan generate:controller ScoreController
app/controllers/ScoreController.php
public function index($level = “normal”)
{
$scoreList = Score::where("level", "=", $level)
->take("5")
->join("users", "user.id", "=", "scores.user_id")
->orderBy(“score”, “desc”);
->get()
->toJson();
return $scoreList;
}
Road map
● Preparing Laravel
– Database and models
– Routes and controllers
● Adding Jquery and custom scripts using blade
● Giving PHP data to Javascript
– The easy way
– The even more easy “Jeffrey” way
● Making a ajax call to a controller
– Using named routes
– Named routes as import
Adding Jquery and custom scripts
● Using Laravel's blade templating engine
● Global scripts/css in master template
● Specific scripts/css in sub views
Code snippet
{{ HTML::script("js/jquery.js") }}
{{ HTML::style("css/style.css") }}
● Using a asset manager
● CodeSleeve/asset-pipeline gives tons of options
Adding Jquery and custom scripts
Using blade
● We are inserting into layouts/default.blade.php:
SCRIPTS
● JQuery + knob
● Game mechanics
● Demo purpose scripts
STYLES
● Fontawesome
● Game css
● Google Orbitron font
Have a look for yourself at layouts/default.blade.php!
Road map
● Preparing Laravel
– Database and models
– Routes and controllers
● Adding Jquery and custom scripts using blade
● Giving PHP data to Javascript
– The easy way
– The even more easy “Jeffrey” way
● Making a ajax call to a controller
– Using named routes
– Named routes as import
Giving PHP data to Javascript
Request
Response Grab response $
Giving PHP data to Javascript
The easy way
Giving PHP data to Javascript
PHP snippet
// Response with variable
$name = “denbatte”;
return View::make(“game”, compact(“name”));
HTML/JS snippet
// Grab response variable
<script> var name = “<?php echo $name; ?>”; </script>
// Laravel blade way
<script> var name = “{{ $name }}”;</script>
● Not very scalabe
● Javascript needs to be inline
Giving PHP data to Javascript
The even more easy
“Jeffrey” way
Giving PHP data to Javascript
PHP snippet
// Response with variable
$name = “denbatte”;
Javascript::put(array("name" => $name));
return View::make(“game”);
● Making use of the laracasts/utilities plugin
● Binds arrays with variables to one view!
● game.blade.php
Have a look for yourself at scoreController.php @ highscore
Giving PHP data to Javascript
● Setup:
● Composer
● Add serviceprovider
● Artisan config:publish
Have a look for yourself at config.php
terminal
user@device: php artisan config:publish laracasts/utilities
Road map
● Preparing Laravel
– Database and models
– Routes and controllers
● Adding Jquery and custom scripts using blade
● Giving PHP data to Javascript
– The easy way
– The even more easy “Jeffrey” way
● Making a ajax call to a controller
– Using named routes
– Named routes as import
Making a ajax call to a controller
Request
Response
Making a ajax call to a controller
Jquery code snippet
$.post("score/{level}").done(function(data) {
var data = $.parseJSON(data);
// Do stuff with the data
}, 'json');
scoreController@index
public function index($level = "normal")
{
$scoreList = Score::where("level", "=", $level)
->take("5")
->join("users", "users.id", "=", "scores.user_id")
->orderBy("score", "DESC")
->get()
->toJson();
return $scoreList;
}
routes.php
Have a look for yourself at scoreController.php @ index | lara...ajax.js
Using named routes
● Named routes? → laravel-js-routes package
– Generates a routes.js helper file in root.
– Gives a Router object
Layout.blade.php
{{ HTML::script("/path/to/routes.js") }}
Layout.blade.php
Router.route(route_name:string, params:array)
https://github.com/fedeisas/laravel-js-routes
Using named routes
● Import generated routes.js using JQuery or require.js
JQuery snippet
$.getScript( "ajax/test.js");
Questions
● Shoot, I will try to answer them now or I will
come back to you later.
● Now lets play this game!

Mais conteúdo relacionado

Mais procurados

Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
Vance Lucas
 

Mais procurados (20)

Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
 
REST API Laravel
REST API LaravelREST API Laravel
REST API Laravel
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Hello World on Slim Framework 3.x
Hello World on Slim Framework 3.xHello World on Slim Framework 3.x
Hello World on Slim Framework 3.x
 
API Development with Laravel
API Development with LaravelAPI Development with Laravel
API Development with Laravel
 
Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentials
 
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
 
Workshop Laravel 5.2
Workshop Laravel 5.2Workshop Laravel 5.2
Workshop Laravel 5.2
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Laravel 101
Laravel 101Laravel 101
Laravel 101
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 

Semelhante a Javascript laravel's friend

nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
patter
 

Semelhante a Javascript laravel's friend (20)

PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Memphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basicsMemphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basics
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework Scala
 
以 Laravel 經驗開發 Hyperf 應用
以 Laravel 經驗開發 Hyperf 應用以 Laravel 經驗開發 Hyperf 應用
以 Laravel 經驗開發 Hyperf 應用
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Laravel & Composer presentation - extended
Laravel & Composer presentation - extendedLaravel & Composer presentation - extended
Laravel & Composer presentation - extended
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Express js
Express jsExpress js
Express js
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
working with PHP & DB's
working with PHP & DB'sworking with PHP & DB's
working with PHP & DB's
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
Laravel & Composer presentation - WebHostFace
Laravel & Composer presentation - WebHostFace Laravel & Composer presentation - WebHostFace
Laravel & Composer presentation - WebHostFace
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Android networking-2
Android networking-2Android networking-2
Android networking-2
 
Presentation laravel 5 4
Presentation laravel 5 4Presentation laravel 5 4
Presentation laravel 5 4
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Javascript laravel's friend

  • 2. Introduction ● Bart (@denbatte) ● Teacher ● PHP/Laravel enthousiast ● Slides will be available on slideshare
  • 3. Objectives ● Creating the best game ever! ● Exploring Laravel by doing the previous. ● Learning how Javascript integrates with Laravel – Not using JS Frameworks (Angular) for now!
  • 4. Preparing Laravel with composer composer.json "require": { "laravel/framework": "4.1.*", "laracasts/utilities": "1.0", // Development packages "way/generators": "2.*", "barryvdh/laravel-ide-helper": "1.*", "fzaninotto/faker": "v1.3.0", "fedeisas/laravel-js-routes": "1.3" } Do not forget to add the serviceProviders at app/config/app.php
  • 5. The game - Login
  • 6. The game - Dashboard
  • 7. Road map ● Preparing Laravel – Database and models – Routes and controllers ● Adding Jquery and custom scripts using blade ● Giving PHP data to Javascript – The easy way – The even more easy “Jeffrey” way ● Making a ajax call to a controller – Using named routes – Named routes as import
  • 8. Preparing the database ● Migration files for users/score table ● Seeding with faker terminal user@device: php artisan generate:migration create_<name>_table user@device: php artisan generate:seed user@device: php artisan migrate –-seed Do not forget to add database settings at app/config/database.php
  • 9. Preparing the database ● Migration files for users/score table ● Seeding with faker terminal user@device: php artisan migrate –-seed Migration file Seed file
  • 10. Generating database models ● A model will make Eloquent understand your data. – User.php is already there – Adding Score.php model terminal user@device: php artisan generate:model Score
  • 11. Preparing routes app/routes.php // Game: sessions resource – login and logout Route::resource('sessions', 'SessionsController'); Route::get('/', 'sessionsController@create'); Route::get('login', 'sessionsController@create'); Route::get('logout', 'sessionsController@destroy'); // Actual game view Route::get('game', "ScoreController@highscore")->before("auth"); // Score: Ajax route retrieving high score Route::post( '/score/{level}', array( 'as' => 'score.index', 'uses' => 'ScoreController@index' ) ); // Score: Ajax route updating player score Route::post( '/score/update', array( 'as' => 'score.update', 'uses' => 'ScoreController@update' ) );
  • 12. Generating controllers terminal user@device: php artisan generate:controller ScoreController app/controllers/ScoreController.php public function index($level = “normal”) { $scoreList = Score::where("level", "=", $level) ->take("5") ->join("users", "user.id", "=", "scores.user_id") ->orderBy(“score”, “desc”); ->get() ->toJson(); return $scoreList; }
  • 13. Road map ● Preparing Laravel – Database and models – Routes and controllers ● Adding Jquery and custom scripts using blade ● Giving PHP data to Javascript – The easy way – The even more easy “Jeffrey” way ● Making a ajax call to a controller – Using named routes – Named routes as import
  • 14. Adding Jquery and custom scripts ● Using Laravel's blade templating engine ● Global scripts/css in master template ● Specific scripts/css in sub views Code snippet {{ HTML::script("js/jquery.js") }} {{ HTML::style("css/style.css") }} ● Using a asset manager ● CodeSleeve/asset-pipeline gives tons of options
  • 15. Adding Jquery and custom scripts Using blade ● We are inserting into layouts/default.blade.php: SCRIPTS ● JQuery + knob ● Game mechanics ● Demo purpose scripts STYLES ● Fontawesome ● Game css ● Google Orbitron font Have a look for yourself at layouts/default.blade.php!
  • 16. Road map ● Preparing Laravel – Database and models – Routes and controllers ● Adding Jquery and custom scripts using blade ● Giving PHP data to Javascript – The easy way – The even more easy “Jeffrey” way ● Making a ajax call to a controller – Using named routes – Named routes as import
  • 17. Giving PHP data to Javascript Request Response Grab response $
  • 18. Giving PHP data to Javascript The easy way
  • 19. Giving PHP data to Javascript PHP snippet // Response with variable $name = “denbatte”; return View::make(“game”, compact(“name”)); HTML/JS snippet // Grab response variable <script> var name = “<?php echo $name; ?>”; </script> // Laravel blade way <script> var name = “{{ $name }}”;</script> ● Not very scalabe ● Javascript needs to be inline
  • 20. Giving PHP data to Javascript The even more easy “Jeffrey” way
  • 21. Giving PHP data to Javascript PHP snippet // Response with variable $name = “denbatte”; Javascript::put(array("name" => $name)); return View::make(“game”); ● Making use of the laracasts/utilities plugin ● Binds arrays with variables to one view! ● game.blade.php Have a look for yourself at scoreController.php @ highscore
  • 22. Giving PHP data to Javascript ● Setup: ● Composer ● Add serviceprovider ● Artisan config:publish Have a look for yourself at config.php terminal user@device: php artisan config:publish laracasts/utilities
  • 23. Road map ● Preparing Laravel – Database and models – Routes and controllers ● Adding Jquery and custom scripts using blade ● Giving PHP data to Javascript – The easy way – The even more easy “Jeffrey” way ● Making a ajax call to a controller – Using named routes – Named routes as import
  • 24. Making a ajax call to a controller Request Response
  • 25. Making a ajax call to a controller Jquery code snippet $.post("score/{level}").done(function(data) { var data = $.parseJSON(data); // Do stuff with the data }, 'json'); scoreController@index public function index($level = "normal") { $scoreList = Score::where("level", "=", $level) ->take("5") ->join("users", "users.id", "=", "scores.user_id") ->orderBy("score", "DESC") ->get() ->toJson(); return $scoreList; } routes.php Have a look for yourself at scoreController.php @ index | lara...ajax.js
  • 26. Using named routes ● Named routes? → laravel-js-routes package – Generates a routes.js helper file in root. – Gives a Router object Layout.blade.php {{ HTML::script("/path/to/routes.js") }} Layout.blade.php Router.route(route_name:string, params:array) https://github.com/fedeisas/laravel-js-routes
  • 27. Using named routes ● Import generated routes.js using JQuery or require.js JQuery snippet $.getScript( "ajax/test.js");
  • 28. Questions ● Shoot, I will try to answer them now or I will come back to you later. ● Now lets play this game!