VOOZH about

URL: https://deepwiki.com/mathsgod/light/10.2-dependencies-and-package-management

⇱ Dependencies and Package Management | mathsgod/light | DeepWiki


Loading...
Last indexed: 31 January 2026 (cf9511)
Menu

Dependencies and Package Management

This document describes the Composer-based dependency management system used by the Light framework, including core required packages, optional feature packages, and the auto-detection pattern for storage backends and authentication providers. For information about environment-specific configuration variables, see Environment Configuration. For cache configuration and performance optimization, see Performance and Caching.

Overview

The Light framework uses Composer for dependency management with a modular approach that separates core functionality from optional features. The system automatically detects the presence of optional packages (such as cloud storage adapters and OAuth providers) at runtime, enabling features only when their dependencies are installed. This allows for minimal installations in resource-constrained environments while supporting rich features when needed.

Sources: composer.json1-65

Dependency Architecture

Functional Dependency Layers


Sources: composer.json10-36 composer.lock1-7

Core Dependencies

Required Packages

The following table lists all required packages that must be installed for the Light framework to function:

PackageVersionPurposeKey Feature
PHP>=8.1Runtime environmentRequired for modern type system and attributes
mathsgod/light-server^1.1HTTP server foundationPSR-7/15 request pipeline, routing
mathsgod/light-graphql^1.2GraphQL layerSchema generation, query execution
mathsgod/light-db^1.5Database abstractionQuery builder, collections, ORM
mathsgod/light-db-graphqlite-mappers^1.0Type mappingAutomatic DB to GraphQL type conversion
mathsgod/light-rbac^1.0AuthorizationRole hierarchy, permission checking
mathsgod/json-to-sql^1.0Schema conversionJSON to SQL DDL translation
mathsgod/mysql-schema-migrate^1.0Schema managementDatabase migration tool
league/container^4.2Dependency injectionPSR-11 container, autowiring
league/flysystem^3.15File storageMulti-backend storage abstraction
league/event^3.0Event systemPSR-14 event dispatcher
firebase/php-jwt^6.11JWT tokensAccess/refresh token generation
web-auth/webauthn-lib^4.9Biometric authFIDO2/WebAuthn passwordless login
endroid/qr-code^4.82FA codesQR code generation for TOTP
laminas/laminas-code^4.7Code generationModel/controller scaffolding
laminas/laminas-diactoros^3.5HTTP messagesPSR-7 request/response objects
symfony/yaml^6.4ConfigurationParse permissions.yml
symfony/cache^6.0CachingPSR-6/16 cache implementation
symfony/console^7.4CLI commandsbin/light command framework
symfony/serializer^6.3SerializationObject normalization
symfony/property-info^6.4ReflectionProperty metadata extraction
symfony/property-access^6.4Property accessDynamic property reading/writing
ramsey/uuid^4.7UUID generationFilesystem drive identifiers
phpmailer/phpmailer^6.8EmailSMTP mail sending
sebastian/diff^4.0DiffingRevision comparison
utopia-php/system^0.9.0System infoServer resource monitoring

Sources: composer.json10-36

Transitive Dependencies

The core packages bring in additional dependencies automatically:


Sources: composer.lock8-2451

Optional Dependencies

Development and Optional Features

The following packages are listed in require-dev and are optional for runtime but enable additional features:

PackageVersionPurposeFeature Enabled
laminas/laminas-httphandlerrunner*HTTP runnerProduction HTTP server integration
google/apiclient^2.15Google APIsGoogle OAuth authentication
league/flysystem-aws-s3-v3^3.24S3 adapterAmazon S3 file storage
alphasnow/aliyun-oss-flysystem^3.4OSS adapterAliyun OSS file storage
hostlink/hostlink-storage-adapter^1.0Hostlink adapterHostlink cloud storage
phpstan/phpstan^2.0Static analysisDevelopment quality checks
phpunit/phpunit^9.6TestingUnit and integration tests

Sources: composer.json38-45

Auto-Detection Pattern

The system uses runtime package detection to enable features conditionally. The Light\App class performs class_exists() checks during initialization to detect installed optional packages and register them dynamically.

Runtime Feature Detection Flow


Implementation Pattern:

The detection follows this pattern in filesystem initialization:


Similarly, OAuth providers are conditionally enabled in AuthController methods based on package availability. If google/apiclient is not installed, the loginWithGoogle mutation is not exposed in the GraphQL schema.

This pattern allows developers to install only the storage adapters they need without requiring all backends in production. The LocalFilesystemAdapter is always available as it's included with the required league/flysystem package.

Sources: composer.json38-45 composer.json18 (league/flysystem required)

Version Management

Version Locking Strategy

The Light framework uses version constraints that balance stability with security updates:

Constraint TypeExamplePackages Using ItRationale
Caret (^)^6.4Most Symfony packages, Laravel packagesAllow minor and patch updates within major version
Specific minimum>=8.1PHP runtimeRequire modern language features
Wildcard (*)*Development tools onlyAlways use latest for dev tools

The composer.lock file pins exact versions of all packages (including transitive dependencies) to ensure reproducible builds:


Key version examples from lock file:

Sources: composer.json10-36 composer.lock1-7 composer.lock476-537 composer.lock1696-1777 composer.lock1555-1635

Updating Dependencies

To update dependencies within version constraints:


Sources: composer.json56-64

Internal Package Ecosystem

The framework is split into separate internal packages for modularity:


Package versions in composer.json:

Each internal package is independently versioned and can be updated separately, though the main framework specifies compatible versions.

Sources: composer.json23-35

Composer Configuration

Autoloading

The framework uses PSR-4 autoloading with additional function files:


All classes under the Light\ namespace are mapped to the src/ directory. The function/base85.php file is loaded on every request to provide global utility functions.

Sources: composer.json47-54

Plugin Configuration

Composer plugins are explicitly allowed for package discovery:


  • php-http/discovery: Enables automatic discovery of PSR-17/18 HTTP implementations
  • tbachert/spi: Service Provider Interface for package integration

Sources: composer.json56-61

Binary Commands

The framework provides a CLI binary installed in vendor bins:


After installation, the bin/light command is available via vendor/bin/light for code generation, database management, and other CLI operations. The binary is implemented as a Symfony Console application that loads commands from the Light\Command namespace. See page 9.1 (CLI Overview) for available commands.

Installed Commands:

  • DbInstallCommand - Schema installation and table management
  • MakeModelCommand - Generate model classes from db.json
  • MakeControllerCommand - Scaffold GraphQL controllers
  • MakeInputCommand - Generate GraphQL input types
  • MakeTsCommand - Generate TypeScript interfaces

Sources: composer.json55

Scripts

Custom Composer scripts for development:


Run tests with: composer test

Sources: composer.json62-64

Installation Scenarios

Minimal Installation

For minimal resource usage (e.g., embedded systems or Docker containers with local storage only):


This installs only the 24 required packages from composer.json require section, excluding:

  • Cloud storage adapters (S3, OSS, Hostlink)
  • OAuth providers (Google Client)
  • Development tools (PHPStan, PHPUnit)
  • HTTP handler runner (laminas/laminas-httphandlerrunner)

Features available with minimal installation:

  • Local filesystem via League\Flysystem\Local\LocalFilesystemAdapter
  • Password authentication via Light\Model\User::verifyPassword()
  • JWT tokens via Firebase\JWT\JWT
  • 2FA TOTP via Light\TwoFactorAuthentication
  • WebAuthn via Webauthn\Server
  • GraphQL API via TheCodingMachine\GraphQLite\SchemaFactory
  • MySQL database via Laminas\Db\Adapter\Adapter

Sources: composer.json10-36 (required packages), composer.json38-45 (optional dev packages)

Full-Featured Installation

For production with all storage backends and OAuth:


Additional features enabled:

  • S3 Storage: Aws\S3\S3Client, detected by Light\App and registered in League\Flysystem\MountManager
  • Aliyun OSS: OSS\OssClient, enables Alibaba Cloud storage backend
  • Hostlink Storage: Hostlink\Storage\HostlinkAdapter, enables Hostlink cloud backend
  • Google OAuth: Google\Client, enables AuthController::loginWithGoogle() mutation
  • Production HTTP Server: Laminas\HttpHandlerRunner\Emitter\SapiEmitter for efficient response emission

GraphQL Schema Impact: When google/apiclient is installed, the loginWithGoogle(code: String!): AuthPayload mutation becomes available in the schema. Without it, attempting to call this mutation results in a schema error.

Sources: composer.json38-45

Development Installation

For local development with testing and analysis tools:


This installs all packages including dev dependencies for running tests and static analysis.

Development tools included:

  • PHPUnit: phpunit/phpunit ^9.6 - Run via composer test or vendor/bin/phpunit tests --verbose
  • PHPStan: phpstan/phpstan ^2.0 - Static analysis to detect type errors
  • Cloud Adapters: All storage backends for testing multi-backend scenarios
  • HTTP Runner: laminas/laminas-httphandlerrunner for integration testing

Running tests:


The test script is defined in composer.json:


Sources: composer.json38-45 (require-dev), composer.json62-64 (scripts)

Dependency Security

Security Advisories

The framework's dependencies are monitored for security vulnerabilities. Several packages include roave/security-advisories in their dev dependencies to prevent installation of known vulnerable versions:

Keeping Dependencies Updated

Regular security updates should be applied:


Sources: composer.lock1-7