Taylor Otwell, the creator of Laravel, speaks highly of the way Laravel implanted a dependency injection mechanism. Dependency injection, or DI for short, is a way to inject classes instead of having to type the complete class name and import it. Implementing it in Laravel takes place through its IoC container. With this container, injecting a class serves a cleaner and more readable code. In this video, take a brief look into this IoC container.
- [Instructor] One of Laravel's strongest features,…is it's Dependency Injection, or DI mechanism.…In the Laravel context,…DI merely means adding a class instance…to another class via it's constructor.…Let's see how painless it is to inject a dependency,…when we want to make a class available to our controller.…For the project, we will need a drop-down menu…with titles such as, Mister, Misses, et cetera.…We're going to use a model to obtain these titles.…
However, since it's a static catalog,…we really don't need to add a table to the database.…A simple way to go, is to create a model,…but not use any of the methods…that will fire any database actions.…Let's start by creating a title model with…php, artisan, make,…colon model, title.…Now let's open our title model,…and add an array of titles.…
Let's go, app, title.…Then we're going to add an array as protected,…titles, array,…equal to an array,…and inside of the array, Mister,…Misses, Miss, Doctor, and MX.…
We'll save, and now let's remove…the inheritant from eloquent.…
Author
Released
8/24/2017- Laravel file and folder structure
- Dependency injection
- Routing requests to controllers
- Loading a view
- Creating a basic Blade template
- Sending data to a view
- Creating and validating forms
- Integrating a database
- Modifying data with Eloquent
- Returning data to a Laravel view
- Adding relational data and concurrent connections
Skill Level Intermediate
Duration
Views
Related Courses
-
PHP: Creating Secure Websites
with Kevin Skoglund4h 15m Intermediate -
Ajax with PHP: Add Dynamic Content to Websites
with Kevin Skoglund3h 37m Intermediate -
MVC Frameworks for Building PHP Web Applications
with Drew Falkman2h 57m Intermediate -
Learning Symfony 3
with Bernardo Pineda1h 46m Intermediate
-
Introduction
-
Welcome49s
-
What you should know1m 8s
-
Using the exercise files1m 57s
-
-
1. Getting Started with Laravel
-
What is Laravel?2m 17s
-
Get a copy of Laravel2m 54s
-
Artisan for developers4m 33s
-
Dependency injection6m 15s
-
Service providers2m 50s
-
Facades and their utility4m 34s
-
-
2. Controlling an Application
-
Routing to controllers5m 16s
-
Loading a view5m 12s
-
3. Views and Blade
-
Send data to a view5m 57s
-
Create forms4m 23s
-
Process form data5m 13s
-
Form validation: Back end2m 36s
-
Form validation: Front end4m 47s
-
4. Introducing Eloquent
-
Introduction to Eloquent2m 48s
-
Set up a database3m 37s
-
Database migrations8m 12s
-
Models in Laravel4m 7s
-
Select data with Eloquent5m 21s
-
Modify data with Eloquent2m 51s
-
Relations in Eloquent5m 49s
-
Select data with raw queries7m 39s
-
Return data to the view7m 4s
-
Add relational data7m 20s
-
Concurrent connections6m 39s
-
-
Conclusion
-
Next steps43s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Dependency injection