111 Flashcards

222

1
Q

Request Lifecycle

A

The entry point for all requests to a Laravel application is the public/index.php file. The index.php file loads the Composer generated autoloader definition, and then retrieves an instance of the Laravel application from bootstrap/app.php script. The first action taken by Laravel itself is to create an instance of the application / service container.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

server meets the following requirements:

A
PHP >= 7.1.3
BCMath PHP Extension
Ctype PHP Extension 
JSON PHP Extension
Mbstring PHP Extension
OpenSSL PHP Extension
PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Homestead

A

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

php artisan route:cache

A

reduces all of your route registrations into a single method call within a cached file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Request Lifecycle…

A

HTTP / Console Kernels
the incoming request is sent to either the HTTP kernel or the console kernel

app/Http/Kernel.php

The HTTP kernel extends the Illuminate\Foundation\Http\Kernel class, which defines an array of bootstrappers that will be run before the request is executed. These bootstrappers configure error handling, configure logging, detect the application environment, and perform other tasks that need to be done before the request is actually handled.

The HTTP kernel also defines a list of HTTP middleware that all requests must pass through before being handled by the application. These middleware handle reading and writing the HTTP session, determining if the application is in maintenance mode, verifying the CSRF token, and more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Request Lifecycle…

A

Service Providers

One of the most important Kernel bootstrapping actions is loading the service providers for your application. All of the service providers for the application are configured in the config/app.php configuration file’s providers array. First, the register method will be called on all providers, then, once all providers have been registered, the boot method will be called.

Service providers are responsible for bootstrapping all of the framework’s various components, such as the database, queue, validation, and routing components. Since they bootstrap and configure every feature offered by the framework, service providers are the most important aspect of the entire Laravel bootstrap process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Request Lifecycle

A

Dispatch Request

Once the application has been bootstrapped and all service providers have been registered, the Request will be handed off to the router for dispatching. The router will dispatch the request to a route or controller, as well as run any route specific middleware.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Service Container

A

The Laravel service container is a powerful tool for managing class dependencies and performing dependency injection. Dependency injection is a fancy phrase that essentially means this: class dependencies are “injected” into the class via the constructor or, in some cases, “setter” methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are Laravel Contract’s ?

A

Laravel’s Contracts are nothing but a set of interfaces that define the core services provided by the Laravel framework.
Read more about laravel Contract’s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Explain Facades in Laravel ?

A

Laravel Facades provides a static like an interface to classes that are available in the application’s service container. Laravel self-ships with many facades which provide access to almost all features of Laravel ’s. Laravel facades serve as “static proxies” to underlying classes in the service container and provide benefits of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods of classes. All of Laravel’s facades are defined in the Illuminate\Support\Facades namespace. You can easily access a facade like so:

use Illuminate\Support\Facades\Cache;

Route::get(‘/cache’, function () {
return Cache::get(‘key’);
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are Laravel eloquent?

A

Laravel’s Eloquent ORM is simple Active Record implementation for working with your database. Laravel provide many different ways to interact with your database, Eloquent is most notable of them. Each database table has a corresponding “Model” which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.

Below is sample usage for querying and inserting new records in Database with Eloquent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are traits in Laravel?

A

PHP Traits are simply a group of methods that you want include within another class. A Trait, like an abstract class cannot be instantiated by itself.Trait are created to reduce the limitations of single inheritance in PHP by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is reverse routing in Laravel?

A

Laravel reverse routing is generating URL’s based on route declarations. Reverse routing makes your application so much more flexible. It defines a relationship between links and Laravel routes. When a link is created by using names of existing routes, appropriate Uri’s are created automatically by Laravel. Here is an example of reverse routing.

// route declaration

Route::get(‘login’, ‘users@login’);
Using reverse routing we can create a link to it and pass in any parameters that we have defined. Optional parameters, if not supplied, are removed from the generated link.

{{ HTML::link_to_action(‘users@login’) }}
It will automatically generate an Url like http://xyz.com/login in view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

List some default packages provided by Laravel 5.6 ?

A

Below are a list of some official/ default packages provided by Laravel

Cashier
Envoy
Passport
Scout
Socialite
Horizon
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain Bundles in Laravel?

A

In Laravel, bundles are also called packages. Packages are the primary way to extend the functionality of Laravel. Packages might be anything from a great way to work with dates like Carbon, or an entire BDD testing framework like Behat.In Laravel, you can create your custom packages too.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List some features of laravel 5.0 ?

A

Laravel 5.0 features

Inbuilt CRSF (cross-site request forgery ) Protection.
Inbuilt paginations
Reverse Routing
Query builder
Route caching
Database Migration
IOC (Inverse of Control) Container Or service container.

17
Q

Dependency injection

A

In software engineering, dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service).

dependencies can be injected at runtime rather than at compile time

There are basically three types of dependency injection:
constructor injection: the dependencies are provided through a class constructor.
setter injection: the client exposes a setter method that the injector uses to inject the dependency.
interface injection: the dependency provides an injector method that will inject the dependency into any client passed to it. Clients must implement an interface that exposes a setter method that accepts the dependency.

Benefits of using DI
Helps in Unit testing.
Boiler plate code is reduced, as initializing of dependencies is done by the injector component.
Extending the application becomes easier.
Helps to enable loose coupling, which is important in application programming.
Disadvantages of DI
It’s a bit complex to learn, and if overused can lead to management issues and other problems.
Many compile time errors are pushed to run-time.
Dependency injection frameworks are implemented with reflection or dynamic programming. This can hinder use of IDE automation, such as “find references”, “show call hierarchy” and safe refactoring.

18
Q

S.O.L.I.D: The First 5 Principles of Object Oriented Design

A
S - Single-responsiblity principle
O - Open-closed principle
L - Liskov substitution principle
I - Interface segregation principle
D - Dependency Inversion Principle
19
Q

Single-responsibility Principle

A

A class should have one and only one reason to change, meaning that a class should have only one job.

20
Q

Open-closed Principle

A

Objects or entities should be open for extension, but closed for modification.

This simply means that a class should be easily extendable without modifying the class itself.

21
Q

Liskov substitution principle

A

Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.

All this is stating is that every subclass/derived class should be substitutable for their base/parent class.

22
Q

Interface segregation principle

A

A client should never be forced to implement an interface that it doesn’t use or clients shouldn’t be forced to depend on methods they do not use.

23
Q

Dependency Inversion principle

A

Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.