<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/context-and-effects-jahojtzh8" -->

---
title: Context and Effects | daily.dev
description: An essay explores how logging in code creates side effects that break function purity and complicate dependency injection, arguing that DI only relocates the...
canonical: https://daily.dev/posts/context-and-effects-jahojtzh8
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Context and Effects | daily.dev
og:description: An essay explores how logging in code creates side effects that break function purity and complicate dependency injection, arguing that DI only relocates the...
og:url: https://daily.dev/posts/context-and-effects-jahojtzh8
og:image: https://api.daily.dev/og/posts/JahojTZh8.png
og:image:alt: Context and Effects
og:image:width: 1200
og:image:height: 630
og:locale: 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.

# Context and Effects

**[Medium](https://daily.dev/sources/medium_js)** · 5 min read · 1 upvotes · 0 comments

## Summary

An essay explores how logging in code creates side effects that break function purity and complicate dependency injection, arguing that DI only relocates the problem of dependencies living longer than needed and threading through call chains. It proposes effect systems as a language-level solution, where function signatures explicitly declare their effects (like Log), allowing compilers to enforce context requirements. A PHP-flavored 'with' syntax is sketched as a hypothetical implementation, referencing an actual PHP RFC for context managers as a step toward this functionality.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@edmond.ht/context-and-effects-c950f838f43b>

## Questions this post answers

### What is a PHP RFC for context managers and what problem does it try to solve?

A PHP RFC proposed introducing context managers, referenced at wiki.php.net/rfc/context-managers, as an attempt to give PHP functionality for making function context and dependencies explicit, similar to effect systems in other languages. It was raised as a step toward addressing hidden side effects like logging and database access that traditional dependency injection does not fully solve.

_daily.dev surfaces PHP language proposals like context managers for developers tracking where the ecosystem is headed._

### Why does dependency injection not solve the problem of side effects like logging in a function?

Dependency injection only relocates dependencies rather than eliminating the underlying issue: it makes providing a logger or database explicit, but says nothing about what a function is allowed to do with that dependency, and it makes functions impure by allowing hidden effects such as writing logs or touching a database that never appear in the function signature.

_Developers weighing DI patterns against effect-based designs can follow this kind of architecture debate on daily.dev._

## Similar posts on daily.dev

- [PonderingEffects](https://daily.dev/posts/ponderingeffects-8uffgotbe) · Lobsters · 0 upvotes · 0 comments
- [A Dependency Is Not Just a Relationship Where One Piece of Code Uses Another](https://daily.dev/posts/a-dependency-is-not-just-a-relationship-where-one-piece-of-code-uses-another-ifwuvqqsh) · Medium · 2 upvotes · 1 comments
- [You don't need an effect system](https://daily.dev/posts/you-don-t-need-an-effect-system-1jg8fivth) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php), [#logging](https://daily.dev/tags/logging), [#dependency-injection](https://daily.dev/tags/dependency-injection)

[View this post on daily.dev](https://daily.dev/posts/context-and-effects-jahojtzh8)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Context and Effects","url":"https://daily.dev/posts/context-and-effects-jahojtzh8","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/context-and-effects-jahojtzh8"},"datePublished":"2026-09-10T21:05:56.153Z","dateModified":"2026-10-15T02:22:49.927Z","description":"An essay explores how logging in code creates side effects that break function purity and complicate dependency injection, arguing that DI only relocates the...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f102c46d02c9951862578829c5e5e134?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f102c46d02c9951862578829c5e5e134?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/context-and-effects-jahojtzh8","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"php,logging,dependency-injection","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Context and Effects"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/context-and-effects-jahojtzh8#faq","mainEntity":[{"@type":"Question","name":"What is a PHP RFC for context managers and what problem does it try to solve?","acceptedAnswer":{"@type":"Answer","text":"A PHP RFC proposed introducing context managers, referenced at wiki.php.net/rfc/context-managers, as an attempt to give PHP functionality for making function context and dependencies explicit, similar to effect systems in other languages. It was raised as a step toward addressing hidden side effects like logging and database access that traditional dependency injection does not fully solve. daily.dev surfaces PHP language proposals like context managers for developers tracking where the ecosystem is headed."}},{"@type":"Question","name":"Why does dependency injection not solve the problem of side effects like logging in a function?","acceptedAnswer":{"@type":"Answer","text":"Dependency injection only relocates dependencies rather than eliminating the underlying issue: it makes providing a logger or database explicit, but says nothing about what a function is allowed to do with that dependency, and it makes functions impure by allowing hidden effects such as writing logs or touching a database that never appear in the function signature. Developers weighing DI patterns against effect-based designs can follow this kind of architecture debate on daily.dev."}}]}
```

