php-edifact/edifact-mapping
PHP library for mapping EDIFACT messages to and from structured PHP data. Define segment and element mappings for orders, invoices, despatch advices and other EDI documents, then parse or generate EDIFACT cleanly in your PHP application.
composer require php-edifact/edifact-mapping. In practice you'll usually get it transitively when you install php-edifact/edifact, which consumes it.vendor/php-edifact/edifact-mapping/src/ for the loader classes (typically MappingProvider and its message/segment/element models), and the shipped XML directory for the actual definitions. Open one file end-to-end — say ORDERS under D96A — because that XML is the schema you're really programming against.EDI\Writer to emit an ORDERS/DESADV/INVOIC and let the mapping enforce segment order and mandatory elements. If you're not writing yet, use it standalone to answer "which segments does ORDERS D96A allow, and which are mandatory?" — that introspection is the fastest way to see the value.use EDI\Mapping\MappingProvider;
use EDI\Writer;
// message type + directory/version; confirm the exact constructor
// signature in src/Mapping/MappingProvider.php for your installed version
$mapping = new MappingProvider('ORDERS', 'D96A');
$writer = new Writer($mapping);
EDI\Parser/Reader, then use the mapping to assert required segments and elements exist before mapping into your DTOs. This is where mappings earn their keep: partner files that "look fine" but violate the schema get rejected with a structural reason instead of blowing up three layers deeper.EdifactSchemaRepository::segmentsFor($type, $directory), elementSpec($tag, $component) — that owns the provider. You get a single seam for caching, testing, and swapping in a custom XML directory, and MappingProvider never leaks into controllers.vendor/.ORDERS:D:01B:UN will not validate against a D96A mapping. Match the mapping to the partner's actual interchange version, not to what your ERP prefers.vendor directories, or Docker builds that strip non-PHP files break it silently. Keep the XML shipped and add a smoke test that loads one mapping.vendor — composer install will overwrite them anyway.How can I help you explore Laravel packages today?