1. Go to this page and download the library: Download azaharizaman/nexus-product library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
azaharizaman / nexus-product example snippets
use Nexus\Product\Services\ProductManager;
use Nexus\Product\Enums\ProductType;
use Nexus\Product\Enums\TrackingMethod;
use Nexus\Product\ValueObjects\Sku;
use Nexus\Uom\ValueObjects\Quantity;
$productManager->createStandaloneVariant(
tenantId: 'tenant-123',
code: 'WIDGET-001',
name: 'Premium Widget',
type: ProductType::STORABLE,
trackingMethod: TrackingMethod::SERIAL_NUMBER,
weight: new Quantity(2.5, 'kg'),
categoryCode: 'HARDWARE'
);
use Nexus\Product\ValueObjects\Barcode;
use Nexus\Product\Enums\BarcodeFormat;
// EAN-13 validation
$barcode = new Barcode('5901234123457', BarcodeFormat::EAN13);
// Barcode service
$barcodeService->validate($barcode); // true if valid checksum
$barcodeService->lookupVariant($barcode); // Find product by barcode
use Nexus\Product\ValueObjects\DimensionSet;
use Nexus\Uom\ValueObjects\Quantity;
$dimensions = new DimensionSet(
weight: new Quantity(5.5, 'kg'),
length: new Quantity(30, 'cm'),
width: new Quantity(20, 'cm'),
height: new Quantity(10, 'cm'),
volume: new Quantity(6, 'L')
);
use Nexus\Product\Services\SkuGenerator;
use Nexus\Sequencing\Contracts\SequenceGeneratorInterface;
$skuGenerator = new SkuGenerator($sequenceGenerator);
$sku = $skuGenerator->generateSku('tenant-123', 'PRODUCT');
// Result: "PRD-2024-00001"
interface ProductVariantInterface {
public function getDefaultRevenueAccountCode(): ?string;
public function getDefaultCostAccountCode(): ?string;
public function getDefaultInventoryAccountCode(): ?string;
}
interface PurchaseOrderLineInterface {
public function getProductVariantId(): ?string;
public function getItemDescription(): string; // Fallback for legacy
}
use Nexus\Product\ValueObjects\Sku;
$sku = new Sku('PRD-2024-00001');
$sku->getValue(); // "PRD-2024-00001"
$sku->toArray(); // ['value' => 'PRD-2024-00001']
use Nexus\Product\ValueObjects\Barcode;
use Nexus\Product\Enums\BarcodeFormat;
$barcode = new Barcode('5901234123457', BarcodeFormat::EAN13);
$barcode->getValue(); // "5901234123457"
$barcode->getFormat(); // BarcodeFormat::EAN13
use Nexus\Product\ValueObjects\DimensionSet;
use Nexus\Uom\ValueObjects\Quantity;
$dimensions = new DimensionSet(
weight: new Quantity(2.5, 'kg'),
length: new Quantity(30, 'cm'),
width: new Quantity(20, 'cm'),
height: new Quantity(15, 'cm')
);
$dimensions->toArray();
// [
// 'weight' => ['value' => 2.5, 'unit' => 'kg'],
// 'length' => ['value' => 30, 'unit' => 'cm'],
// ...
// ]
enum ProductType: string {
case STORABLE = 'storable'; // Physical goods with inventory tracking
case CONSUMABLE = 'consumable'; // Items consumed without stock tracking
case SERVICE = 'service'; // Intangible services
}
enum TrackingMethod: string {
case NONE = 'none'; // No tracking
case LOT_NUMBER = 'lot_number'; // Batch/lot tracking
case SERIAL_NUMBER = 'serial_number'; // Unique instance tracking
}
enum BarcodeFormat: string {
case EAN13 = 'ean13'; // European Article Number (13 digits)
case UPCA = 'upca'; // Universal Product Code (12 digits)
case CODE128 = 'code128'; // High-density alphanumeric
case QR = 'qr'; // QR Code (2D)
case CUSTOM = 'custom'; // Custom format
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.