Logo of the Laravel framework

Laravel


Languages

Links

Articles

Something nice about the Laravel Framework

  • PHP Lambo Meme
  • Some controversial choices e.g.
    • the global DI Container, which enables prose-like code, considered to be elegant by many
    • many strings e.g. in validation (Rules 'required|string|max:255'), or access control

Facades

TODO: Maybe we should simply link to the official docs.

You might see something like this in Laravel code samples:

$price = Cache::get('product-price[123]');

Specifically I am referring to the Cache::get part. In Laravel, this is called a facade, which lets you access functionality in a comfortable way.

If you would step through the debugger, what happens here is roughly something like this:

// Somewhere deep in the framework a global container is constructed.
$container = new DependencyContainer();
// This container is made available _globally_
GlobalDependencyContainer::setInstance($container);
// Then the cache module of laravel registers an instance of a cache as a
$container->set('cache', new Cache());
//
$cache = GlobalDependencyContainer::getInstance
$price = Cache::get('product-price[123]');