Category: Laravel, Laravel, PHP, PHP, api, api

It can completely change the way you design and develop your application solving critical architectural bottlenecks, allowing you to build large systems built around decoupled, independent and reusable components.

Think about Log (you can log to files, syslog, papertrail, slack, etc), Cache (you can cache your data into files, redis, memecached, etc)., Session (you can store PHP sessions using files, databases, etc)., and others general purpose components.

We can also switch from one driver to another at runtime if necessary: Obviously it works only if you have properly configured the driver in the configuration file.

Add the code below in your AppServiceProvider: We also create the Firewall Facade to access the binded service in a convenient way: Finally create the config\firewall.php configuration file to store the specific configuration options for each driver: Once we have configured our component, that is, registering a facade as Firewall, and setting up the config file, we can easily get an instance of the FirewallManager and access the driver functionalities: By default it use the log driver, so you should see the log entry: With the FirewallManager in place we can now easily develop new firewall implementations to interact with other systems.

You can add the new createCloudflareDriver() method to define the creation logic: Now you are free to switch to this new driver or configure it as default driver in your environment file: Laravel makes it painless to create driver-based components using the Manager class.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners