Book Image

Hands-On Full Stack Web Development with Angular 6 and Laravel 5

By : Fernando Monteiro
Book Image

Hands-On Full Stack Web Development with Angular 6 and Laravel 5

By: Fernando Monteiro

Overview of this book

Angular, considered as one of the most popular and powerful frontend frameworks, has undergone a major overhaul to embrace emerging web technologies so that developers can build cutting-edge web applications. This book gives you practical knowledge of building modern full-stack web apps from scratch using Angular with a Laravel Restful back end. The book begins with a thorough introduction to Laravel and Angular and its core concepts like custom errors messages, components, routers, and Angular-cli, with each concept being explained first, and then put into practice in the case-study project. With the basics covered, you will learn how sophisticated UI features can be added using NgBootstrao and a component-based architecture. You will learn to extend and customize variables from Bootstrap CSS framework. You will learn how to create secure web application with Angular and Laravel using token based authentication. Finally, you will learn all about progressive web applications and build and deploy a complete fullstack application using Docker and Docker-compose. By the end of this book, you'll gain a solid understanding of Angular 6 and how it interacts with a Laravel 5.x backend
Table of Contents (13 chapters)

Creating controllers and routes

We are almost there, but we have a few steps left so that we can finish our API. Now, is time to create the API controller and API routes.

With the newest version (5.6) from Laravel we have a new command available to do this task. This is the --api flag. Let's see how it works in practice.

Creating and updating the controller function

  1. Open your Terminal window and type the following command:

php artisan make:controller API/BuilderController --api

Note that the --api flag creates four methods for us inside the BuilderController class:

  • index() = GET
  • store() = POST
  • show($id) = GET
  • update(Request $request, $id) = PUT
  • destroy($id) = POST
  1. Open project/app/Http/Controllers/API/BuilderController...