# Service locator: an anti-pattern

DevFeed: [Service locator: an anti-pattern](<https://devfeed.tech/articles/service-locator-an-anti-pattern-44266.md>)

Original publisher: [Read original article](<https://stitcher.io/blog/service-locator-anti-pattern>)

Author: Brent

Published: 2018-08-10T00:00:00Z

Content type: opinion

Language: en

Sources: [stitcher.io](<https://devfeed.tech/sources/stitcher-io.md>)

Topics: [Laravel](<https://devfeed.tech/topics/laravel.md>), [runtime errors](<https://devfeed.tech/topics/runtime-errors.md>), [Code](<https://devfeed.tech/topics/code.md>), [container](<https://devfeed.tech/topics/container.md>), [class](<https://devfeed.tech/topics/class.md>), [ide](<https://devfeed.tech/topics/ide.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [ide](<https://devfeed.tech/tags/ide.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [runtime-errors](<https://devfeed.tech/tags/runtime-errors.md>)

## AI overview

A Laravel developer examines the service locator pattern and argues that retrieving dependencies from the service container can increase runtime errors, obscure a class's dependencies, and raise cognitive load. The article contrasts runtime failures with errors detectable at compile time or through IDE and static analysis tools.

## Source excerpt

Read the full post on https://stitcher.io/blog/service-locator-anti-pattern