---
title: "Laravel In Depth: Understanding Laravel Macros"
url: https://daily.dev/posts/laravel-in-depth-understanding-laravel-macros-fvlctu9i9
source_url: https://www.linkedin.com/pulse/laravel-depth-understanding-macroables-eyad-mohammed-osama/
type: article
source: "Community Picks"
published: 2024-07-11T14:59:14.815Z
updated: 2024-10-05T16:16:50.701Z
tags: ["webdev", "php", "laravel"]
reading_time: 7
upvotes: 61
comments: 2
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel In Depth: Understanding Laravel Macros

**[Community Picks](https://daily.dev/sources/community)** · 7 min read · 61 upvotes · 2 comments

## Summary

Laravel macros allow developers to dynamically add new methods to existing classes at runtime, enhancing the functionality of Laravel's core classes without modifying the source code. Through the use of macros and mixins, developers can increase code reusability and create concise, readable code. This guide explores the definition, purpose, and benefits of macroables, demonstrates how to register and invoke macros, and provides real-world examples including the use of mixins for more organized code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.linkedin.com/pulse/laravel-depth-understanding-macroables-eyad-mohammed-osama/>

## Community discussion

Top comments from developers on daily.dev.

**@msamgan** · 1 upvotes

> this is a really good article.

**@alkiviadisdoulgeris** · 1 upvotes

> Bad practise in my opinion.
> 1) You do not change the structure of a class at runtime, and continue to write code after it to use the 'macros'. Bad practise.
> 2) just extend the class, provide interface and implement it also with a trait if you need. Must faster, cleaner no 'behind the scenes' stuff which will definetely lead to hell.
> 3) No matter the bad thing, also looks like reinventing the wheel for no reason at all. And it is not something that I see for the first time regarding Laravel.
> 4) Not to mention naming conventions. Naming methods like properties and vice versa.

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/laravel-in-depth-understanding-laravel-macros-fvlctu9i9)
