se / opentrans
Allows to read, create and write OpenTRANS compatible documents
Installs: 839
Dependents: 1
Suggesters: 0
Security: 0
Stars: 15
Watchers: 3
Forks: 11
Open Issues: 2
Requires
- php: >=5.3.3
- jms/serializer: >=0.11,<=0.14
- symfony/event-dispatcher: 2.3.*
- symfony/serializer: 2.3.*
Requires (Dev)
- phploc/phploc: *
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-11-14 03:45:39 UTC
README
Allows you to read, create and write OpenTRANS compatible documents from PHP
Dev branch is master branch.
Table of Contents
Installation
The recommended way to install is through Composer.
{ "require": { "se/opentrans": "dev-master" } }
Usage
Build document
Assuming you already have a builder (See document factory)
<?php use \SE\Component\OpenTrans; $document = $builder->getDocument(); $document->getHeader()->getOrderInfo()->setOrderId('00000000001'); $orderLine1 = new OpenTrans\Node\Order\ItemNode(); $orderLine1->setLineId('P00000001'); $document->addItem($orderLine1); $xml = $builder->serialize();
Returns:
<?xml version="1.0" encoding="ISO-8859-1"?> <ORDER version="1.0" type="standard"> <ORDER_HEADER> <CONTROL_INFO> <GENERATOR_INFO/> <GENERATION_DATE/> </CONTROL_INFO> <ORDER_INFO> <ORDER_ID>00000000001</ORDER_ID> </ORDER_INFO> </ORDER_HEADER> <ORDER_ITEM_LIST> <ORDER_ITEM> <LINE_ITEM_ID>P00000001</LINE_ITEM_ID> </ORDER_ITEM_LIST> <ORDER_SUMMARY/> </ORDER>
Document factory
<?php use \SE\Component\OpenTrans; // Pick a factory to create your document (i.e. an Order) $loader = new OpenTrans\NodeLoader(); $factory = new OpenTrans\DocumentFactory\OrderFactory($loader); $builder = new OpenTrans\DocumentBuilder($factory); $builder->build(); // bootstraps the default document structure $document = $builder->getDocument(); // ... build your document
Resolve document factory by document type
<?php use \SE\Component\OpenTrans; // Let the DocumentFactoryResolver pick the factory you need $loader = new OpenTrans\NodeLoader(); $factoryClass = OpenTrans\DocumentFactory\DocumentFactoryResolver::resolveFactory( $loader, OpenTrans\DocumentType::DOCUMENT_ORDER ); $factory = new $factoryClass($loader); $builder = new OpenTrans\DocumentBuilder($factory); $builder->build(); // bootstraps the default document structure $document = $builder->getDocument(); // ... build your document
Run tests
$> vendor/bin/phpunit
Symfony2 bundle
This library is integrated into Symfony2 through the OpenTransBundle.
Roadmap
- Implement Document types
- (x) Order
- ( ) Invoice
- ( ) OrderChange
- ( ) OrderResponse
- ( ) Quotation
- ( ) RFQ
- ( ) ReceiptAcknowledgement