Download the PHP package gemvc/apm-contracts without Composer

On this page you can find all versions of the php package gemvc/apm-contracts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package apm-contracts

gemvc_header_for_github

GEMVC APM Contracts

License: MIT PHP Version

APM contracts, interfaces, and abstract base class for GEMVC framework. This package provides the foundation for all Application Performance Monitoring (APM) providers, enabling developers to create pluggable APM solutions that work seamlessly with GEMVC.

Table of Contents

Overview

The gemvc/apm-contracts package provides:

This package is always installed with GEMVC (required by gemvc/library), providing a standardized way to integrate any APM solution (TraceKit, Datadog, New Relic, Elastic APM, OpenTelemetry, etc.) without changing application code.

📦 Installation

This package is automatically installed when you install GEMVC:

It's also required by APM provider packages:

🏗️ Architecture

Universal Pattern: Just like UniversalQueryExecuter abstracts database connections (PDO/OpenSwoole/MongoDB), ApmFactory abstracts APM providers (TraceKit/Datadog/NewRelic). The core framework uses ApmFactory::create() without knowing which provider is installed.

Creating an APM Provider Package

Follow these steps to create your own APM provider package for GEMVC:

Step 1: Create Package Structure

Step 2: Set Up composer.json

Step 3: Create Provider Class

Create src/Gemvc/Core/Apm/Providers/YourProvider/YourProvider.php:

Step 4: Create Toolkit Class

All APM providers must have a Toolkit class for client-side integration and management. Create src/Gemvc/Core/Apm/Providers/YourProvider/YourProviderToolkit.php:

Toolkit Features:

The abstract base class provides all helper methods for API calls, error handling, and JSON parsing. You only need to implement the endpoint paths.

Step 5: No Registration Required!

The factory automatically discovers your provider! No need to modify ApmFactory.php.

The factory uses dynamic class instantiation based on the APM_NAME environment variable:

This follows the Open/Closed Principle - you can add new providers without modifying the factory!

Step 6: Configuration

Users configure your provider in .env:

🔧 How It Works

1. Framework Initialization

When GEMVC starts processing a request:

2. Factory Pattern

ApmFactory reads APM_NAME from environment and creates the appropriate provider:

3. Provider Initialization

Each provider extends AbstractApm, which:

  1. Stores Request object - For accessing HTTP metadata
  2. Sets common properties - From $config array (if provided) or $_ENV variables:
    • $apmName - From $config['apm_name'] or $_ENV['APM_NAME']
    • $enabled - From $config['enabled'] or $_ENV['APM_ENABLED'] (accepts 'true', '1', 'false', '0', or boolean)
    • $sampleRate - From $config['sample_rate'] or $_ENV['APM_SAMPLE_RATE'] (clamped to 0.0-1.0)
    • $traceResponse, $traceDbQuery, $traceRequestBody - From config or environment
  3. Loads provider-specific configuration - Via loadConfiguration() (implemented by provider, can override common properties)
  4. Initializes root trace - Via initializeRootTrace() (implemented by provider)
  5. Registers shutdown function - To flush traces after HTTP response

4. Span Management

Throughout the request lifecycle, the framework calls:

5. Request Object Integration

The APM instance is stored in Request object for sharing:

This allows all layers (Controller, UniversalQueryExecuter, Response, etc.) to access the same APM instance.

6. Toolkit Usage

APM toolkits are instantiated separately and provide client-side integration features:

📚 API Reference

ApmInterface

All APM providers must implement:

AbstractApm

Provides shared functionality:

Note: The init() method is designed for setup/configuration processes (CLI commands or GUI tools), not for runtime object creation. The constructor automatically loads configuration from environment variables during normal operation.

ApmFactory

Universal factory methods (no provider-specific code):

Provider Naming Convention:

ApmToolkitInterface

Contract for all APM provider toolkits. Toolkits handle client-side integration and management:

Configuration Methods:

Account Management:

Health Monitoring:

Metrics & Alerts:

Webhooks:

Billing:

AbstractApmToolkit

Base class providing shared functionality for all toolkits:

Provider toolkits extend this class and implement abstract methods for provider-specific endpoint paths.

💡 Examples

Example: Simple APM Provider

Example: Using APM in Custom Code

Example: Using APM Toolkit

🔗 Related Packages

📝 Environment Variables

Core APM Variables

Provider-Specific Variables

Each provider may define additional variables (e.g., TRACEKIT_API_KEY, DATADOG_API_KEY).

🛠️ Development Setup

This package uses PHPStan stubs for development to avoid circular dependencies with gemvc/library:

Note: gemvc/library is not in the require section to prevent circular dependencies during development. The package will work correctly when installed as a dependency of gemvc/library or APM provider packages.

🤝 Contributing

To add a new APM provider:

  1. Create a new package following the structure above
  2. Submit a PR to apm-contracts to register your provider in ApmFactory
  3. Update documentation with your provider's configuration

📄 License

MIT License - see LICENSE file for details.

Credits

Part of the GEMVC PHP Framework built for Microservices ecosystem.


All versions of apm-contracts with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gemvc/apm-contracts contains the following files

Loading the files please wait ...