Giter Site home page Giter Site logo

opentrans's Introduction

OpenTrans

Latest Stable Version SensioLabsInsight

Allows you to read, create and write OpenTRANS compatible documents from PHP

Dev branch is master branch.

Build Status

Table of Contents

Installation

Usage

Roadmap

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

opentrans's People

Contributors

jkahnt avatar sveneisenschmidt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

opentrans's Issues

Semantical Error

Hello Sven,

today i use your opentrans lib....
All things are working well, but when i want to serialize like in your example i get the following error:

Fatal error: Uncaught Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@jms\Serializer\Annotation\Expose" in property SE\Component\OpenTrans\Node\AbstractNode::$customEntries does not exist, or could not be auto-loaded. in C:\nginx-1.15.8\html\bmecat\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\AnnotationException.php:54 Stack trace: #0 C:\nginx-1.15.8\html\bmecat\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\DocParser.php(734): Doctrine\Common\Annotations\AnnotationException::semanticalError('The annotation ...') #1 C:\nginx-1.15.8\html\bmecat\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\DocParser.php(663): Doctrine\Common\Annotations\DocParser->Annotation() #2 C:\nginx-1.15.8\html\bmecat\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\DocParser.php(354): Doctrine\Common\Annotations\DocParser->Annotations() #3 C:\nginx-1.15.8\html\bmecat\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\AnnotationReader.php(254): Doctrine in C:\nginx-1.15.8\html\bmecat\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\AnnotationException.php on line 54

Here is the code i use:

`<?php

use \SE\Component\OpenTrans;

//$serializer = \JMS\Serializer\SerializerBuilder::create()->build();

// 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

$document->getHeader()->getOrderInfo()->setOrderId('00000000001');

$orderLine1 = new OpenTrans\Node\Order\ItemNode();
$orderLine1->setLineId('P00000001');

$document->addItem($orderLine1);
//var_dump($document);

$xml = $builder->serialize(); //-> here i get the error!!!!
`

Thank you in advance for your support.

Yours sincereley

Mika

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.