Laravel – Contracts

Laravel contracts are a set of interfaces with various functionalities and core services provided by the framework. For example, Illuminate\Contracts\Queue\Queue contract uses a method which is needed for queuing jobs and Illuminate\Contracts\Mail\Mailer uses the method for sending emails. Every contract defined includes corresponding implementation of the framework. All the Laravel contracts are available in …

Read More »

Laravel – Facades

Facades provide a static interface to classes that are available in the application’s service container. Laravel facades serve as static proxies to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods. Create Facade The following are the steps to create Facade …

Read More »

Laravel – Event Handling

Events provide a simple observer implementation which allows a user to subscribe and listen to various events triggered in the web application. All the event classes in Laravel are stored in the app/Events folder and the listeners are stored in the app/Listeners folder. The artisan command for generating events and listeners in your web …

Read More »

Laravel – Error Handling

Most web applications have specific mechanisms for error handling. Using these, they track errors and exceptions, and log them to analyze the performance. In this chapter, you will read about error handling in Laravel applications. 'debug' => env('APP_DEBUG', false), Important Points Before proceeding further to learn in detail about error …

Read More »

Laravel – Ajax

Ajax (Asynchronous JavaScript and XML) is a set of web development techniques utilizing many web technologies used on the client-side to create asynchronous Web applications. Import jquery library in your view file to use ajax functions of jquery which will be used to send and receive data using ajax from the …

Read More »

Laravel – Sending Email

Laravel uses free feature-rich library SwiftMailer to send emails. Using the library function, we can easily send emails without too many hassles. The e-mail templates are loaded in the same way as views, which means you can use the Blade syntax and inject data into your templates. The following table shows the …

Read More »

Laravel – Validation

Validation is the most important aspect while designing an application. It validates the incoming data. By default, base controller class uses a ValidatesRequests trait which provides a convenient method to validate incoming HTTP requests with a variety of powerful validation rules. Available Validation Rules in Laravel Laravel will always check for errors …

Read More »

Laravel – Session

Sessions are used to store information about the user across the requests. Laravel provides various drivers like file, cookie, apc, array, Memcached, Redis, and database to handle session data. By default, file driver is used because it is lightweight. Session can be configured in the file stored at config/session.php. Accessing Session Data To access the …

Read More »

Laravel – Localization

Localization feature of Laravel supports different language to be used in application. You need to store all the strings of different language in a file and these files are stored at resources/views directory. You should create a separate directory for each supported language. All the language files should return an array of …

Read More »