Laravel 8 Tutorial - Facades
In this tutorial, we are going to learn about facades in Laravel 8.
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.
So, let's create a custom facade. Go to the project and inside the app
folder, create a new folder. Let's say the folder name is PaymentGateway
.
Inside the PaymentGateway
folder, create a file. Let's say the file name is Payment.php
. Inside the Payment.php
file, write the following code:
<?php
namespace App\PaymentGateway;
class Payment {
public function process()
{
echo "Processing the payment";
}
}
Now, create another file. Let's say the file name is PaymentFacade.php
. Inside the PaymentFacade.php
file, just write here:
>