Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Component Model Laravel Package

nette/component-model

Nette Component Model provides a lightweight component hierarchy for PHP apps. It supports parent/child relationships, naming, lookup, and lifecycle hooks, making it easy to build reusable UI or service components that can be composed, traversed, and managed consistently.

View on GitHub
Deep Wiki
Context7
v4.0.0-RC1

A focused, modern major release. The component model drops legacy baggage, demands PHP 8.3+, and ships a smarter monitoring system that finally behaves predictably when listeners reshape the tree. If you've been carrying around deprecated attached()/detached() hooks or the magic getComponents() parameters, this is your cue to clean up – the payoff is a leaner, stricter, more reliable foundation.

💥 Breaking Changes

  • Monitoring handlers now fire top-down (ancestor → descendant). When a subtree is attached, monitor() listeners are invoked from the outermost ancestor inward, matching the natural order of tree construction. The new implementation is robust against listeners that mutate the tree mid-flight: it re-checks validity before descending into children, deduplicates so the same listener never runs twice, and guards against reentry to prevent infinite loops. If your code relied on the old ordering, review listeners that depend on sibling or parent state.

  • attached() / detached() methods removed. These long-deprecated lifecycle hooks are gone. Migrate to explicit callbacks: replace overridden attached($obj) / detached($obj) with monitor($type, attached: ..., detached: ...). Calling monitor() with no handler at all now throws an InvalidStateException – at least one of attached or detached is required.

  • Container::getComponents() parameters removed. The method now takes no arguments and returns a plain array of immediate children (previously iterable). The old recursive flag and filter-type argument are gone – passing them throws a DeprecatedException. For recursive traversal use getComponentTree() instead. The internal RecursiveComponentIterator has been removed.

  • IContainer::addComponent() signature tightened. Now declared as addComponent(IComponent $component, ?string $name): static. Implementations and callers must match the new return type hint.

  • Nette\SmartObject dropped from Component. The component no longer pulls in the SmartObject trait, and the magic $name, $parent, and $components properties are gone. Use the explicit methods (getName(), getParent(), getComponents()) directly.

  • IComponent::NAME_SEPARATOR removed. Use IComponent::NameSeparator instead.

  • PHP 8.3 required.

v4.0.0

A focused, modern major release. The component model drops legacy baggage, demands PHP 8.3+, and ships a smarter monitoring system that finally behaves predictably when listeners reshape the tree. If you've been carrying around deprecated attached()/detached() hooks or the magic getComponents() parameters, this is your cue to clean up – the payoff is a leaner, stricter, more reliable foundation.

💥 Breaking Changes

  • Monitoring handlers now fire top-down (ancestor → descendant). When a subtree is attached, monitor() listeners are invoked from the outermost ancestor inward, matching the natural order of tree construction. The new implementation is robust against listeners that mutate the tree mid-flight: it re-checks validity before descending into children, deduplicates so the same listener never runs twice, and guards against reentry to prevent infinite loops. If your code relied on the old ordering, review listeners that depend on sibling or parent state.

  • attached() / detached() methods removed. These long-deprecated lifecycle hooks are gone. Migrate to explicit callbacks: replace overridden attached($obj) / detached($obj) with monitor($type, attached: ..., detached: ...). Calling monitor() with no handler at all now throws an InvalidStateException – at least one of attached or detached is required.

  • Container::getComponents() parameters removed. The method now takes no arguments and returns a plain array of immediate children (previously iterable). The old recursive flag and filter-type argument are gone – passing them throws a DeprecatedException. For recursive traversal use getComponentTree() instead. The internal RecursiveComponentIterator has been removed.

  • IContainer::addComponent() signature tightened. Now declared as addComponent(IComponent $component, ?string $name): static. Implementations and callers must match the new return type hint.

  • Nette\SmartObject dropped from Component. The component no longer pulls in the SmartObject trait, and the magic $name, $parent, and $components properties are gone. Use the explicit methods (getName(), getParent(), getComponents()) directly.

  • IComponent::NAME_SEPARATOR removed. Use IComponent::NameSeparator instead.

  • PHP 8.3 required.

v3.2.0

A transitional release ahead of 4.0. Nothing is removed yet, this version just lights up deprecation notices on things that will disappear in 4.0, so you can get your code ready in peace.

💥 Deprecated (will be removed in 4.0)

  • Magic properties Component::$name, Component::$parent and Container::$components – use getName(), getParent(), getComponents() instead.
  • Calling monitor($type) without callbacks – pass them directly: monitor($type, $attached, $detached). Overriding attached() / detached() in subclasses is on its way out.
  • Constant IComponent::NAME_SEPARATOR – switch to IComponent::NameSeparator (the deprecation is now reported via the native #[\Deprecated] attribute).
v3.1.4

A focused maintenance release for the Component layer. The headline is hardening of the monitor callback machinery: nested re-entry is now safely guarded, callbacks are normalized to \Closure for consistent deduplication, and the whole codebase has been brought under mandatory static analysis with nette/phpstan-rules.

  • Reentry protection for monitor callbacksComponent::refreshMonitors() now refuses to re-enter itself while listeners are running. If a listener removes and re-adds the same component (or otherwise triggers another refresh), each component is processed exactly once instead of looping or double-firing.
  • Reliable callback deduplication – switched the in-array check for monitor callbacks to loose comparison. Closures are never === to each other unless they are literally the same instance, so the previous strict check silently let duplicates through.
  • Adopted nette/phpstan-rules – stricter ruleset enabled, with a dedicated tests/types/component-types.php driving type tests.
v3.1.3

support for PHP 8.5

v3.1.2
  • support for PHP 8.5
  • optimized global function calls
v3.1.1
  • support for PHP 8.4
  • improved phpDoc
v3.1.0
  • requires PHP 8.1
  • uses PHP 8.1 features
  • added Container::getComponentTree()
  • Container::getComponents() parameters are silently deprecated, returns array when $deep is false (BC break)
v3.0.3
  • composer: allows nette/utils 4.0
  • constants are PascalCase
v3.0.2
  • support for PHP 8.1
v3.0.1
  • Container: component name may be number or null
  • Container: added const NAME_REGEXP
  • added .phpstorm.meta.php
  • fixed bugs reported by PHPStan

For the details you can have a look at the diff.

v3.0.0

Features

  • requires PHP 7.1
  • uses declare(strict_types=1)
  • uses PHP 7.1 scalar and return type hints
  • Component::monitor accepts callbacks
  • added trait ArrayAccess
  • Component: More informative message in case that name is not available (#5)

Changes

  • Component::__construct($parent) is deprecated (BC break)
  • Container::getComponents(): removed child-first option (BC break)
  • Component: removed constructor (BC break)
  • Container: name must be string, int is allowed via ArrayAccess (BC break)
  • Component: attached() and detached() marked as deprecated in favor of monitoring callbacks
v2.4.0
  • Component::monitor() accepts callbacks
  • Component: attached() and detached() marked as deprecated in favor of monitoring callbacks
  • added trait ArrayAccess
  • Component::__construct($parent, $name) is deprecated (BC break)
v2.3.1
  • supports PHP up to 7.2
  • coding style: fixes, lowercase true/false/null
  • @return self -> static
  • composer: accepts nette 3.0
  • renamed parameter $need -> $throw

For the details you can have a look at the diff.

v2.2.5
  • @return self -> static
  • Container::getComponent() optimization

For the details you can have a look at the diff.

v2.3.0
  • requires PHP 5.6
  • uses Nette\SmartObject
  • Container::getComponent() optimization
  • Component::__construct() parameters $parent & $name are deprecated

For the details you can have a look at the diff.

v2.2.4
  • Container: shows suggestions for missing components

For the details you can have a look at the diff.

v2.2.3
  • travis: migrating to container-based infrastructure
  • improved coding style

For the details you can have a look at the diff.

v2.2.2
  • Component: attached() is called only once for each object #2

For the details you can have a look at the diff.

v2.2.1
  • Container::getComponent() uses better exception message when component has parent #1
v2.2.0

The first standalone release. For more information see readme.md.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony