Skip to content

Bram's Blog

I write about my discoveries and practices while writing software, mainly Laravel, Vue.js and TypeScript.

Contextual Attributes in Laravel

As of Laravel v11.14.0 you can use contextual attributes to add custom logic to dependency injection.

This useful feature has been utilised internally in Laravel to provide us with useful attributes like #[CurrentUser] and #[Cache('apc')].

In this article I will share some useful contextual attributes that I've been using.