azaharizaman/nexus-manufacturing

Framework-agnostic manufacturing and production management for Nexus ERP - BOM, Work Orders, Routings, MRP, CRP with ML-powered demand forecasting

Maintainers

Package info

github.com/azaharizaman/nexus-manufacturing

pkg:composer/azaharizaman/nexus-manufacturing

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0-alpha1 2026-05-05 02:28 UTC

This package is auto-updated.

Last update: 2026-05-05 02:59:16 UTC


README

PHP Version License Tests

A comprehensive, framework-agnostic manufacturing management package for PHP 8.3+

The Manufacturing package provides enterprise-grade production management capabilities including Bill of Materials (BOM), Work Orders, Routings, Material Requirements Planning (MRP), and Capacity Requirements Planning (CRP).

โœจ Features

Core Capabilities

  • ๐Ÿ“‹ Bill of Materials (BOM)

    • Multi-level BOMs with unlimited nesting
    • Phantom (non-stocked) components
    • Versioning with effectivity dates
    • Cycle detection for circular references
    • Configurable BOMs for variants
  • ๐Ÿ”„ Routings & Operations

    • Operation sequencing with work centers
    • Setup, run, and queue times
    • Overlapping operations
    • Alternate routings
    • Subcontract operations
  • ๐Ÿ“ Work Orders

    • Full lifecycle management (Draft โ†’ Planned โ†’ Released โ†’ In Progress โ†’ Completed โ†’ Closed)
    • Material reservation and issue tracking
    • Operation completion recording
    • Scrap tracking
    • Sub-assemblies support
  • ๐Ÿ“Š MRP Engine

    • Gross-to-net requirements calculation
    • Time-phased planning buckets
    • Multiple lot-sizing strategies:
      • Fixed Order Quantity
      • Economic Order Quantity (EOQ)
      • Period Order Quantity (POQ)
      • Least Unit Cost
    • Lead time offsetting
    • Net change vs regenerative modes
  • โšก Capacity Planning

    • Finite and infinite capacity loading
    • Work center calendar integration
    • Capacity profiles and utilization
    • Planning horizon zones (Frozen/Slushy/Liquid)
    • Intelligent overload resolution suggestions
  • ๐Ÿ”ฎ Demand Forecasting

    • ML-powered predictions integration
    • Historical fallback with confidence tracking
    • Seasonal adjustment support
    • Forecast accuracy metrics

๐Ÿ“ฆ Installation

composer require azaharizaman/nexus-manufacturing

๐Ÿš€ Quick Start

Basic BOM Management

use Nexus\Manufacturing\Services\BomManager;
use Nexus\Manufacturing\ValueObjects\BomLine;

// Create BOM manager with repository dependency
$bomManager = new BomManager($bomRepository);

// Create a new BOM
$bom = $bomManager->create(
    productId: 'PROD-001',
    version: '1.0',
    type: 'manufacturing',
    lines: [],
    effectiveFrom: new DateTimeImmutable('2024-01-01')
);

// Add components
$bomManager->addLine($bom->getId(), new BomLine(
    productId: 'COMP-001',
    quantity: 2.0,
    uomCode: 'EA',
    lineNumber: 10,
    scrapFactor: 0.05
));

$bomManager->addLine($bom->getId(), new BomLine(
    productId: 'COMP-002',
    quantity: 1.5,
    uomCode: 'KG',
    lineNumber: 20,
));

// Explode BOM to get all materials
$materials = $bomManager->explode($bom->getId(), quantity: 100);

Work Order Lifecycle

use Nexus\Manufacturing\Services\WorkOrderManager;
use Nexus\Manufacturing\Enums\WorkOrderStatus;

$workOrderManager = new WorkOrderManager($repository, $bomManager, $routingManager);

// Create work order
$workOrder = $workOrderManager->create(
    productId: 'PROD-001',
    quantity: 100.0,
    plannedStartDate: new DateTimeImmutable('2024-02-01'),
    plannedEndDate: new DateTimeImmutable('2024-02-15'),
    bomId: 'bom-001',
    routingId: 'routing-001'
);

// Release for production
$workOrderManager->release($workOrder->getId());

// Start production
$workOrderManager->start($workOrder->getId());

// Record operation completion
$workOrderManager->completeOperation(
    workOrderId: $workOrder->getId(),
    operationSequence: 10,
    completedQty: 100.0,
    scrapQty: 2.0,
    laborHours: 8.5
);

// Complete and close
$workOrderManager->complete($workOrder->getId());
$workOrderManager->close($workOrder->getId());

MRP Calculation

use Nexus\Manufacturing\Services\MrpEngine;
use Nexus\Manufacturing\ValueObjects\PlanningHorizon;
use Nexus\Manufacturing\Enums\LotSizingStrategy;

$mrpEngine = new MrpEngine(
    $bomManager,
    $inventoryProvider,
    $demandProvider,
    $plannedOrderRepository
);

// Define planning horizon
$horizon = new PlanningHorizon(
    startDate: new DateTimeImmutable('2024-01-01'),
    endDate: new DateTimeImmutable('2024-03-31'),
    bucketSize: 7, // Weekly buckets
    frozenDays: 14,
    slushyDays: 28
);

// Run MRP
$result = $mrpEngine->run(
    productIds: ['PROD-001', 'PROD-002'],
    horizon: $horizon,
    lotSizingStrategy: LotSizingStrategy::ECONOMIC_ORDER_QUANTITY
);

// Process planned orders
foreach ($result->getPlannedOrders() as $order) {
    echo sprintf(
        "Product: %s, Qty: %.2f, Due: %s\n",
        $order->getProductId(),
        $order->getQuantity(),
        $order->getDueDate()->format('Y-m-d')
    );
}

Capacity Planning

use Nexus\Manufacturing\Services\CapacityPlanner;
use Nexus\Manufacturing\Enums\CapacityLoadType;

$capacityPlanner = new CapacityPlanner(
    $workCenterRepository,
    $workOrderRepository,
    $routingManager,
    $capacityResolver
);

// Check capacity for work center
$profile = $capacityPlanner->getCapacityProfile(
    workCenterId: 'WC-001',
    startDate: new DateTimeImmutable('2024-02-01'),
    endDate: new DateTimeImmutable('2024-02-28'),
    loadType: CapacityLoadType::FINITE
);

// Get utilization by period
foreach ($profile->getPeriods() as $period) {
    echo sprintf(
        "%s: %.1f%% utilized\n",
        $period->getDate()->format('Y-m-d'),
        $period->getUtilizationPercent()
    );
}

// Get resolution suggestions for overloads
$suggestions = $capacityPlanner->getResolutionSuggestions('WC-001', $overloadPeriod);
foreach ($suggestions as $suggestion) {
    echo sprintf(
        "Action: %s, Estimated Savings: %.1f hours\n",
        $suggestion->getAction()->value,
        $suggestion->getEstimatedImpact()
    );
}

๐Ÿ“‚ Package Structure

src/
โ”œโ”€โ”€ Contracts/           # 27 Interfaces
โ”‚   โ”œโ”€โ”€ BomInterface.php
โ”‚   โ”œโ”€โ”€ BomManagerInterface.php
โ”‚   โ”œโ”€โ”€ WorkOrderInterface.php
โ”‚   โ”œโ”€โ”€ MrpEngineInterface.php
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ Enums/              # 8 Enums
โ”‚   โ”œโ”€โ”€ WorkOrderStatus.php
โ”‚   โ”œโ”€โ”€ BomType.php
โ”‚   โ”œโ”€โ”€ LotSizingStrategy.php
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ ValueObjects/       # 13 Value Objects
โ”‚   โ”œโ”€โ”€ BomLine.php
โ”‚   โ”œโ”€โ”€ Operation.php
โ”‚   โ”œโ”€โ”€ PlannedOrder.php
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ Exceptions/         # 13 Exceptions
โ”‚   โ”œโ”€โ”€ BomNotFoundException.php
โ”‚   โ”œโ”€โ”€ CircularBomException.php
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ Events/            # 11 Domain Events
โ”‚   โ”œโ”€โ”€ WorkOrderReleasedEvent.php
โ”‚   โ””โ”€โ”€ ...
โ””โ”€โ”€ Services/          # 9 Service Classes
    โ”œโ”€โ”€ BomManager.php
    โ”œโ”€โ”€ WorkOrderManager.php
    โ”œโ”€โ”€ MrpEngine.php
    โ”œโ”€โ”€ CapacityPlanner.php
    โ””โ”€โ”€ ...

๐Ÿ”Œ Integration with Nexus Packages

Nexus\Inventory

// Implement InventoryDataProviderInterface
class InventoryAdapter implements InventoryDataProviderInterface
{
    public function __construct(
        private readonly StockManagerInterface $stockManager
    ) {}
    
    public function getOnHandQuantity(string $productId, string $warehouseId): float
    {
        return $this->stockManager->getAvailableStock($productId, $warehouseId);
    }
}

Nexus\MachineLearning

// Implement ForecastProviderInterface for ML predictions
class MlForecastAdapter implements ForecastProviderInterface
{
    public function __construct(
        private readonly AnomalyDetectionServiceInterface $mlService
    ) {}
    
    public function getForecast(string $productId, DateTimeImmutable $date): ?DemandForecast
    {
        $prediction = $this->mlService->predict('demand_forecast', [
            'product_id' => $productId,
            'date' => $date->format('Y-m-d'),
        ]);
        
        return new DemandForecast(
            productId: $productId,
            forecastDate: $date,
            quantity: $prediction['quantity'],
            confidence: ForecastConfidence::from($prediction['confidence'])
        );
    }
}

๐Ÿ“‹ Requirements

  • PHP 8.3 or higher
  • PSR-4 autoloading
  • PSR-3 Logger (optional)

Required Dependencies

  • psr/log ^3.0

Suggested Dependencies

  • azaharizaman/nexus-inventory - For stock integration
  • azaharizaman/nexus-product - For product data
  • azaharizaman/nexus-machine-learning - For demand forecasting
  • azaharizaman/nexus-event-stream - For event sourcing

๐Ÿ“– Documentation

๐Ÿงช Testing

# Run all tests
composer test

# Run with coverage
composer test -- --coverage-html coverage/

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license.

๐Ÿค Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

๐Ÿ“š References