10. Laravel
What is the MVC architecture and how does Laravel implement it?
JuniorAnswer: MVC stands for Model-View-Controller.
- Model: Represents the data structure (Eloquent).
- View: Displays the data (Blade templates).
- Controller: Handles logic and user input.
What is Eloquent ORM?
JuniorAnswer: Laravel's built-in Object-Relational Mapper that allows you to interact with your database using PHP objects instead of raw SQL.
What is Blade?
JuniorAnswer: Blade is Laravel's powerful and simple templating engine, allowing you to use plain PHP in your templates with a clean syntax.
What is Routing in Laravel?
JuniorAnswer: Mapping HTTP requests (URLs) to specific controller actions or closures.
What are Named Routes?
JuniorAnswer: Assigning a name to a route to allow generating URLs or redirects by referencing the name instead of the raw URL.
What are Route Groups?
JuniorAnswer: A way to group multiple routes that share common attributes (like middleware or prefixes).
What are Seeders and Factories?
JuniorAnswer:
- Seeders: Populate the database with test/dummy data.
- Factories: Define the blueprint for generating dummy model data.
What is Soft Delete?
JuniorAnswer: Marking a record as deleted without actually removing it from the database, typically using a deleted_at column.
What is the Laravel Service Container?
MiddleAnswer: A powerful tool for managing class dependencies and performing dependency injection. Service Container Deep Dive
What are Collections?
MiddleAnswer: A wrapper around PHP arrays that provides a powerful, fluent interface for manipulating data (e.g., map, filter, reduce).
What is Middleware?
MiddleAnswer: A filter that inspects and filters HTTP requests entering your application (e.g., authentication, logging).
What are Service Providers?
MiddleAnswer: The central place of all Laravel application bootstrapping. They bind services into the Service Container.
What are Migrations?
MiddleAnswer: Version control for your database, allowing you to define your table structure in PHP code.
What is the difference between Authentication and Authorization?
MiddleAnswer:
- Authentication: Verifying who the user is (e.g., login).
- Authorization: Verifying what the user is allowed to do (e.g., permissions).
What are Facades in Laravel?
SeniorAnswer: They provide a "static" interface to classes available in the Service Container. They serve as "proxy" classes for accessing underlying implementations.
What are Events and Listeners?
SeniorAnswer: A way to decouple components in your application. An event is dispatched, and one or more listeners react to it.
What are Contracts in Laravel?
SeniorAnswer: A set of interfaces that define the core services provided by the framework. They allow for swapping underlying implementations.
What are Service Container and Service Provider roles?
SeniorAnswer:
- Service Container: The registry of all dependencies.
- Service Provider: The classes that register and boot those dependencies into the container.