If you have been around for many years you would remember PHP as just a scripting language to be used inside HTML pages. It was really great, if you think that most sites would have to be done using plain C or Perl languages. In the beginning PHP FI was just that.
But the PHP language became very popular due to its simplicity. It evolved fast throughout the years.
Since it got better support for modern programming approaches, like OOP, MVC and ORM, it has gained a lot of support from its users and, at first, a lot of small library classes started to pop up and being freely hosted in sites like PHPClasses.org
Later on, especially since PHP 4, application frameworks started to appear. FLOSS, CodeIgniter and CakePHP were the most famous, along with Zend, but they started to lag behind with the release of PHP 5 due to the need and will to keep backwards compatibility with the old version and all its users.
This unwillingness, in the pure tradition of free software, originated some forks, like FuelPHP, from developers that wished to move on and use the full strength of PHP 5.
Some new frameworks, like Symfony, also began to emerge, all with something different in style, functionality or approach.
Laravel, the subject of this book, took a different approach from all the predecessors to avoid many of the problems and mistakes previous full stack frameworks did.
The developers decided to make a robust component-based framework on top of the successful and excellent Symfony framework, but also using the “good parts” of other frameworks and libraries, like SwiftMail for email processing.
If you never worked with a PHP framework then you should start with Laravel and this book is, although short, a great one for it.
From this book you will learn just the essential on the last version of this framework with simple examples and very easy to understand language suitable for even the novice PHP developer seeking to start developing or migrating his/her apps from another framework or even converting his/her old non-OOP scripts.
If you are already a seasoned Laravel 4 developer and want to have a reference for the new version then this book was specifically written for you.
As the author says “this book will give you a tour of Laravel and its core features”, so it will guide you from understanding the Laravel wording and concepts to know, through simple examples, all the basics about Laravel and its tools; like Eloquent ORM, virtual development environment Homestead and its powerful command line tool Artisan.
First of all, of course, knowledge of PHP and its related technologies are implied, as is some knowledge on OOP. That said lets start touring.
Chapter 1 gives you an introduction to frameworks and why they can improve your development and your productivity and introduces you to the Model-View-Controller paradigm on which Laravel is based.
It also introduces you to the concepts and features of Laravel and its new application’s general structure and conventions. At the end you can learn some tips on how to migrate your older Laravel’s applications to the new version.
Laravel is much more than just a framework and it includes a set of tools to fasten your work so in Chapter 2 you will learn how to setup a development environment using Composer, a dependency manager, to deal with the installation of all the third parties components that Laravel may need and that are not included in its core source.
You will also learn how to use Homestead, a Vagrant based Virtual Machine box that will allow you to create a full server ready to work with Laravel and without fussing around with your system.
At the end of the chapter you will learn how to create your first Laravel application inside Homestead and how to perform your daily work with it using Homestead (or you can just use ssh or Putty if you are working on Windows or Mac OS X).
Now that you already have your environment created and that you have your Laravel also installed in Homestead it’s time to start building your first application.
That is what you will do in Chapter 3. You will start by planning the URLs and entities that you will use. Learn how to troubleshoot and solve common issues when getting started. After this initial steps you will learn how to define routes and their actions, as well as models and relationships.
Having done that you may need to have a database for your application so you will learn how to setup your database and how to work with Laravel’s ORM Eloquent. At the end of the chapter you will be presented with Blade, Laravel’s template language to create your interface layouts.
Chapter 4 is all about Eloquent ORM. You will learn how to use it for every action that concerns databases.
Although it covers a lot, Eloquent is so feature-rich that the book does not cover all of its features. Neverthless, it covers the most important aspects and you will know how to save and retrieve data, create relations of varying complexity between your data models and also how to handle events raised during your data model’s life cycle.
In Chapter 5 you will learn the importance of testing your applications and you will see how Laravel 5 was built from the ground up to facilitate it. It comes with everything you will need to get started, including helpers to test your application.
In this chapter, you will see how Laravel makes it very simple to get started with testing. In this introduction to testing, the author looks at the advantages of writing tests for your application, how to prepare your tests, the software design patterns that Laravel fosters, what is Mockery and how to use it to test objects in isolation, and introduce you to the built-in features and helpers that facilitate testing.
One of the best things that today’s most used PHP frameworks and applications have is command line tools to fasten your development and automation. Drupal as Drush, WordPress as WP-Cli, Symfony as Pake, just to mention a few.
In Chapter 6 you will be presented with Laravel’s powerful command line tool, Artisan, and will learn to use it for everything you may need, including rolling your own Artisan commands and how to schedule commands to automate everyday’s web site tasks.
Chapter 7 is the last one and it’s about securing your application and user authentication. In order to do that you will improve the application you started in chapter 3 by adding a simple authentication system and tackle any security issues we have in the existing code base.
So you will learn how to configure and use the authentication services, what is the concept of middleware and how to apply it to specific routes, how to validate data and form requests.
You will also learn what are the most common security vulnerabilities and how Laravel can help you write more secure code.
At the end of the book there’s an appendix, a non-numbered chapter, with lots of very useful information and code. I will just quote the beginning of it:
“Laravel comes with several utilities that help you perform specific tasks, such as sending e-mails, queuing functions, and manipulating files. It ships with a ton of handy utilities that it uses internally; the good news is that you can also use them in your applications. This chapter will present the most useful utilities so you do not end up rewriting a function that already exists in the framework!
The structure of this chapter is partly based on Jesse O’Brien’s cheat sheet, which is accessible at https://cheats.jesse-obrien.ca/ . The examples are based on Laravel’s tests as well as its official documentation and API.”
Now all the Essential on Laravel is presented to you so you just need to start coding. I hope you enjoy Laravel as much as I do.
Neverthless, if you are willing to know more about what modern PHP programming and Laravel is or just want to get a fast update on what’s new in its version 5, then you should read “Laravel 5 Essentials”.
Laravel is one of the most exciting of the newer PHP frameworks and it will gain market share in the near future. It’s already the most starred PHP framework on Github and that says a lot about its popularity, so you should really consider to have it as one of your expertise areas.
This book is, for sure, a must have and a very good starting point for all PHP newcomers and old Laravel developers.
Originaly published at PHPClasses.org
Entrepreneur. Project Manager, Web Strategist and Application Developer. Particularly interested in client / server systems and design of relational databases, Usability, UX and Accessibility, Security, Authentication and authorization in distributed software development. Always keen to be part of interesting projects, particularly in the spirit of FLOSS. Also interested in governance, ethics and transparency. Remote work evengelist.