azaharizaman / nexus-manufacturing
Framework-agnostic manufacturing and production management for Nexus ERP - BOM, Work Orders, Routings, MRP, CRP with ML-powered demand forecasting
Package info
github.com/azaharizaman/nexus-manufacturing
pkg:composer/azaharizaman/nexus-manufacturing
Requires
- php: ^8.3
- psr/log: ^3.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
- azaharizaman/nexus-event-stream: dev-main
- azaharizaman/nexus-inventory: dev-main
- azaharizaman/nexus-machine-learning: dev-main
- azaharizaman/nexus-product: dev-main
- azaharizaman/nexus-uom: dev-main
- azaharizaman/nexus-warehouse: dev-main
- azaharizaman/nexus-workflow: dev-main
This package is auto-updated.
Last update: 2026-05-05 02:59:16 UTC
README
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 integrationazaharizaman/nexus-product- For product dataazaharizaman/nexus-machine-learning- For demand forecastingazaharizaman/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
- IMPLEMENTATION_SUMMARY.md - Implementation details
- REQUIREMENTS.md - Package requirements
- TEST_SUITE_SUMMARY.md - Test documentation