VOOZH about

URL: https://deepwiki.com/friendsofhyperf/components/1.3-installation-and-setup

⇱ Installation and Setup | friendsofhyperf/components | DeepWiki


Loading...
Last indexed: 14 February 2026 (15d5ca)
Menu

Installation and Setup

This page describes the installation procedures for the friendsofhyperf/components monorepo and its individual components. It covers system requirements, installation methods, component registration, and configuration publishing procedures.

For information about the monorepo architecture and the "replace" directive strategy, see Monorepo Architecture and Component Registry. For a complete list of available components, see Component Catalog.


System Requirements

The following software versions are required to use any component from this monorepo:

RequirementVersion
PHP>= 8.1
Hyperf Framework>= 3.1.0
Coroutine EngineSwoole or Swow extension
Composer>= 2.0

Sources: composer.json16-18 README.md28-32


Installation Methods

The monorepo supports two installation approaches: installing all components as a suite or installing individual components on demand.

Complete Suite Installation

Installing the complete package provides all 50+ components through Composer's "replace" directive:


This single command makes all components available because composer.json119-168 declares a replace section that maps each individual package name to the monorepo version. When you require friendsofhyperf/components, Composer treats it as if you had installed all individual packages.

Sources: composer.json119-168 README.md36-40

Individual Component Installation

To install specific components independently:


Each component exists as a separate package on Packagist and can be required individually. The component's dependencies are resolved automatically through its own composer.json file (e.g., src/sentry/composer.json24-47).

Sources: README.md42-55


Installation Decision Flow


Sources: composer.json119-168 composer.json171-237 README.md36-63


Component Registration Architecture

All components use Hyperf's ConfigProvider pattern for automatic registration. The registration process occurs during Hyperf's bootstrap phase.


Each component declares its ConfigProvider class in composer.json256-302 For example:

  • FriendsOfHyperf\Sentry\ConfigProvider at line 294
  • FriendsOfHyperf\Cache\ConfigProvider at line 260
  • FriendsOfHyperf\Helpers\ConfigProvider at line 273

The ConfigProvider class returns an array defining:

  • dependencies: DI container bindings
  • listeners: Event listener registrations
  • commands: Console command classes
  • aspects: AOP aspect classes
  • publish: Configuration files to publish

Sources: composer.json256-302 src/sentry/composer.json60-67


PSR-4 Autoloading Structure

Components are organized under PSR-4 namespaces mapped to their source directories:

NamespaceDirectoryExample Class
FriendsOfHyperf\Sentry\src/sentry/src/FriendsOfHyperf\Sentry\Tracer
FriendsOfHyperf\Cache\src/cache/src/FriendsOfHyperf\Cache\Repository
FriendsOfHyperf\Helpers\src/helpers/src/FriendsOfHyperf\Helpers\Functions
FriendsOfHyperf\Http\Client\src/http-client/src/FriendsOfHyperf\Http\Client\PendingRequest
.........

The complete mapping is defined in composer.json171-221

Additionally, several components provide global function files that are auto-loaded via the files directive in composer.json222-237:

  • src/helpers/src/Functions.php - Global helper functions
  • src/sentry/src/Function.php - Sentry helper functions
  • src/encryption/src/Functions.php - Encryption helpers
  • And others

Sources: composer.json171-237


Configuration Publishing

Some components require configuration files to be published to your application's config/autoload/ directory.

Publishing Command Syntax


Components Requiring Configuration

Not all components require explicit configuration publishing. Components that typically need configuration include:

ComponentConfiguration FileKey Settings
sentryconfig/autoload/sentry.phpDSN, tracing options, feature flags
telescopeconfig/autoload/telescope.phpStorage driver, record mode, watchers
triggerconfig/autoload/trigger.phpMySQL binlog connection, consumers
cacheconfig/autoload/cache.phpDriver configuration, default store
lockconfig/autoload/lock.phpLock driver, connection pools
mailconfig/autoload/mail.phpSMTP configuration, from address

Components like helpers, macros, and support work immediately after installation without additional configuration.

Sources: README.md59-63


Post-Installation Verification

Verify Autoloading

After installation, verify that component classes are autoloadable:


Verify ConfigProvider Registration

Check that ConfigProviders are registered by examining Hyperf's provider collection:


Verify Helper Functions

If friendsofhyperf/helpers is installed, test global functions:


The helper functions are defined in src/helpers/src/Functions.php and auto-loaded via composer.json228

Sources: composer.json222-237 src/helpers/src/Functions.php


Component Dependencies

Some components have dependencies on other components or Hyperf packages. These are resolved automatically by Composer.

Foundation Components

These components provide base functionality used by others:

ComponentPurposeDependents
supportBase utilities, Collection, Arr, Str classesMost components
macrosRequestInterface extensionshelpers

Example: Sentry Dependencies

The Sentry component requires several packages as defined in src/sentry/composer.json24-37:


And suggests optional dependencies in src/sentry/composer.json39-46:


Sources: src/sentry/composer.json24-47


Testing Infrastructure Setup

For development and testing, the monorepo includes test infrastructure configuration.

Test Dependencies

Development dependencies are defined in composer.json44-117 and include:

  • pestphp/pest - Testing framework
  • mockery/mockery - Mocking library
  • pestphp/pest-plugin-faker - Fake data generation

Test Configuration

Test setup is centralized in tests/Pest.php1-98 which:

  • Registers the base TestCase class for all tests
  • Defines component-specific test groups (e.g., cache, sentry, helpers)
  • Configures mocking for validation and configuration interfaces
  • Provides helper functions like faker() and test_property()

Example test group registration from tests/Pest.php19-37:


Sources: composer.json44-117 tests/Pest.php1-98


Common Installation Issues

Missing PHP Extensions

Symptom: Installation fails with "ext-openssl is missing"

Solution: Install required PHP extensions listed in composer.json18:


Hyperf Version Mismatch

Symptom: Dependency resolution fails with version conflicts

Solution: Ensure Hyperf version >= 3.1.0 is installed. Check your composer.json constraints.

ConfigProvider Not Loading

Symptom: Component features not available after installation

Solution:

  1. Clear Hyperf's configuration cache: rm -rf runtime/container/
  2. Restart the Hyperf server
  3. Verify the component's ConfigProvider is listed in composer.json extra section

Sources: composer.json16-18 composer.json256-302