{"id":19674828,"url":"https://github.com/bfgasparin/nfeeasy","last_synced_at":"2025-10-15T07:41:33.739Z","repository":{"id":57026149,"uuid":"77388664","full_name":"bfgasparin/NFeEasy","owner":"bfgasparin","description":"A wrapper to manage NFe files.","archived":false,"fork":false,"pushed_at":"2017-01-04T16:19:29.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-10T04:17:06.707Z","etag":null,"topics":["nfe","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bfgasparin.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-26T14:24:34.000Z","updated_at":"2016-12-26T15:30:36.000Z","dependencies_parsed_at":"2022-08-23T15:00:29.194Z","dependency_job_id":null,"html_url":"https://github.com/bfgasparin/NFeEasy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgasparin%2FNFeEasy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgasparin%2FNFeEasy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgasparin%2FNFeEasy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfgasparin%2FNFeEasy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfgasparin","download_url":"https://codeload.github.com/bfgasparin/NFeEasy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240983403,"owners_count":19888682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nfe","php"],"created_at":"2024-11-11T17:19:55.104Z","updated_at":"2025-10-15T07:41:33.644Z","avatar_url":"https://github.com/bfgasparin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NFeEasy\n\n## Introduction\n\nNFeEasy is a wrapper to manage NFe files.\n\n## Requirements\n\n* PHP 7.0.13 or later\n\n## Instalation\n\n### Composer\n\nYou and install via composer:\n\n    $ composer require nfe-easy/nfe-easy\n\nand use composer autoload:\n\n```php\nrequire_once('vendor/autoload.php');\n```\n\n### Manual Instalation\n\nIf you don't want to use Composer, download the latest version of **NefEasy** and include the `init.php` file:\n\n```php\nrequire_once('/path/to/nfeasy/init.php');\n```\n\nYou will also need to dowload the **NfeEasy** php dependencies and autoload then \nmanually. See `composer.json` to see NfeEasy dependencies. \n\n## How to use\n\nTo use the NfeEasy, just pass the xml nfe file content to the XmlInvoiceBuilder\nand it will returns the PHP objects representing the given NFe.\n\n```php\nXmlInvoiceBuilder::::create(\n    file_get_contents('path/to//my/invoice.xml')\n); // returns an instance of NFeEasy\\Invoice\n```\n\n## Domain Objects\n\nEach Domain from NFe file is represented by an NFeEasy object class. These\nclasses are called **Domain Object Classes**.\n\nThe list of Domains Object Classes includes:\n\n* `NFeEasy\\Invoice`\n* `NFeEasy\\Product`\n* `NFeEasy\\Emitter`\n* `NFeEasy\\Receiver`\n* `NFeEasy\\Address`\n\nA full `NFe` file is represented by a relationship between one or more **NFeEasy Domain Objects Classes**.\n\nThe NFeEasy Domain Object Classes contain the data extracted from the NFe file.\nThe data is diviled between the NfeEasy Domain Object Classes.\n\nFor a full NfeEasy reprentation, use the\n`NFeEasy\\Builder\\XmlInvoiceBuilder::create` method. \nIt will return an `NFeEasy\\Invoice` instance.\n\n\n### Invoice\n\nThe `NFeEasy\\Invoice` represents the NFe file itself, and contains \ndata to indentity the NFe. \n\nAll other Domain Object Classes resides below `Invoice` Object.\n\nThe table bellow describes all attributes you can access from\n`NFeEasy\\Invoice` class:\n\nAttribute        | Type                 | Description\n---------------- | -------------------- | ------------\n`cUF`            | string               |\n`cNF`            | string               | Transaction Nature Id\n`natOp`          | string               | Transaction Nature Description\n`indPag`         | string               | Payment Id (0 = Entrada / 1 = Saída)\n`mod`            | string               |\n`serie`          | string               | Invoice Serie\n`nNF`            | string               | Invoice Number\n`dhEmi`          | string               | Emission Date\n`tpNF`           | string               | Invoice Type Id\n`idDest`         | string               |\n`cMunFG`         | string               |\n`tpImp`          | string               |\n`tpEmis`         | string               |\n`cDV`            | string               |\n`tpAmb`          | string               |\n`finNFe`         | string               |\n`indFinal`       | string               |\n`indPres`        | string               |\n`procEmi`        | string               |\n`verProc`        | string               | Version\n`products`       | Collection(Product)  | A list of `Product` for this Invoice\n`additionalInfo` | string               | Addicional Information\n`emitter`        | Emitter              | The Invoice `Emitter`\n`receiver`       | Receiver             | The Invoice `Receiver`\n\n\n### Product\n\n`NFeEasy\\Product` represents an Invoice`s product.\nIt contains informations like the name of the product, the NCM, the value, the quantity the taxes, and other product related things.\n\nThe table bellow describes all attributes you can access from\n`NFeEasy\\Product` class:\n\n\nAttribute        | Type                 | Description\n---------------- | -------------------- | ------------\n`cProd`          | string               | Product Id\n`cEAN`           | string               |\n`xProd`          | string               | Product Description\n`NCM`            | string               | Nomenclatura Comum do Mercosul / Sistema Harmonizado\n`CEST`           | string               |\n`CST`            | string               | Table CST - ICMS\n`CFOP`           | string               | Codigo Fiscal de Operações e Prestações\n`uCom`           | string               | Invoice Number\n`qCom`           | string               | Emission Date\n`vUnCom`         | string               | Invoice Type Id\n`vProd`          | string               | Product Value\n`cEANTrib`       | string               |\n`uTrib`          | string               | Unit Type (UN, CX)\n`qTrib`          | string               |\n`vUnTrib`        | string               | Unit Value\n`indTot`         | string               | Total Value (nItemPed*intTotal)\n`xPed`           | string               |\n`nItemPed`       | string               | Quantity\n`nFCI`           | string               |\n\n## Emitter\n\n`NFeEasy\\Emitter` represents the NFe emitter\n\nThe table bellow describes all attributes you can access from\n`NFeEasy\\Product` class:\n\nAttribute        | Type                 | Description\n---------------- | -------------------- | ------------\n`CNPJ`           | string               | The CNPJ\n`xNome`          | string               | The Emitter name\n`xFant`          | string               | Trading name\n`IE`             | string               |\n`IEST`           | string               |\n`CRT`            | string               |\n`address`        | Address              | The Emitter Address\n\n## Receiver\n\n`NFeEasy\\Receiver` represents the NFe Receiver\n\nThe table bellow describes all attributes you can access from\n`NFeEasy\\Product` class:\n\nAttribute        | Type                 | Description\n---------------- | -------------------- | ------------\n`CNPJ`           | string               | The CNPJ\n`xNome`          | string               | The Receiver name\n`IE`             | string               |\n`indIEDest`      | string               |\n`address`        | Address              | The Receiver Address\n\n\n## Address\n\n`NFeEasy\\Address` represents an address object\n\nThe table bellow describes all attributes you can access from\n`NFeEasy\\Address` class:\n\nAttribute        | Type                 | Description\n---------------- | -------------------- | ------------\n`xLgr`           | string               | The Street name\n`nro`            | string               | the Street number\n`xBairro`        | string               | The Neighborhood name\n`cMun`           | string               | The District Code\n`xMun`           | string               | The Destrict name\n`UF`             | string               | The District\n`CEP`            | string               | The CEP\n`cPais`          | string               | The Country Code\n`xPais`          | string               | The Country Name\n`fone`           | string               | The phone number\n\n\n## Creating Domain Objects\n\nYou can create Domain Object classes individually. Just use \nthe method `created` from the respective object\npassing the parameters you wnat to populate into the object:\n\n```php\n$address = Address::create([\n    'xLgr' =\u003e 'Some address street',\n    'nro' =\u003e '207'\n]); // returns an NFeEasy\\Address\n```\n\nIf you dont't want to create the domain objects individually, you can \npass all data directy to the `NfeEasy\\Invoice`:\n\n```php\n$invoice = Invoice::create([\n    'cUF' =\u003e '32',\n    'natOp' =\u003e 'Venda Sub / Venda Mer',\n    'addicionalInfo' =\u003e 'Some Info',\n    // ...\n    'emitter' =\u003e [\n        'xNome' =\u003e 'Emitter Name',\n        'CNPJ' =\u003e '23740049120232'\n        // ...\n    ],\n    'receiver' =\u003e [\n        'xNome' =\u003e 'Receiver Name',\n        'CNPJ' =\u003e '40193549120112'\n        // ...\n    ],\n    'products' =\u003e [\n        [\n            'cProd' =\u003e '13'\n            'xProd' =\u003e 'Shampoo'\n            // ...\n        ],\n        [\n            'cProd' =\u003e '345'\n            'xProd' =\u003e 'Soap'\n            // ...\n        ],\n        // ...\n    ]\n]); // returns an NFeEasy\\Invoice\n```\n\n## Attributes\n\nAfter a Domain Object is created, you can access the data by access attributes by its names:\n\n```php\n$product = Product::create([\n    'cProd' =\u003e '12'\n    'xProd' =\u003e 'Notebook'\n]);\n\necho $product-\u003exProd; // prints 'Shampoo'\n```\n\nYou can access child objects by the attributes names too:\n\n```php\n$emitter = Emitter::create([\n    'xNome' =\u003e 'Andrew'\n    'CNPJ' =\u003e '23740049120232',\n    'address' =\u003e [\n        'xLgr' =\u003e 'Rua Ivaí',\n        'nro' =\u003e 207,\n        'xBairro' =\u003e 'Tatuapé'\n    ],\n]);\n\n$emitter-\u003eaddress;  // returns an instance of NfeEasy\\Address;\n\necho $emitter-\u003eaddress-\u003exBairro; prints 'Tatuapé'\n```\n\n## Collections\n\nArray of Domain Objects are treated as Collections into NfeEasy. All Object Collections are represented by an instance of `Illuminate\\Support\\Collection`.\n\nCollections in NfeEasy are used for:\n\n* `products` attribute into `Invoice` Object \n\nFor example, to return the collection of products from an Invoice, use:\n\n```php\n$products $invoice-\u003eproducts;  // Return an instance of `Illuminate\\Support\\Collection`.\n```\n\nTo filter products with value greater than 20, use:\n\n```php\n$products = $invoice-\u003eproducts-\u003efilter(function ($product, $key){\n    return $product-\u003evProd \u003e 20;\n});\n```\n\nFor all `Illuminate\\Support\\Collection` available methods, see [Illuminate Collection Docs](https://laravel.com/docs/5.3/collections#method-filter).\n\n## Serialization\n\nAll Domain objects implements `Illuminate\\Contracts\\Support\\Arrayable` and `Illuminate\\Contracts\\Support\\Arrayable\\Jsonable`.\n\nSo you can transform the all NfeEasy Domain objects easily:\n\n```php\n$invoice =\u003e Invoice::create([\n    // attributes data\n]);\n\n$invoice-\u003etoArray(); // converts the domains objects into arrays\n\n$invoice-\u003etoJson(); // converts the domains objects into a json string\n\n(string)$invoice; // converts the domains objects into a json string\n\n```\n\n## Tests\n\nNfeEasy uses [PHPUnit](https://phpunit.de) unit tests for better reliablility and security.\n\nTo run all tests, justs go to the project folder and type:\n\n    $ phpunit\n\n\n##License\n\nNfeEasy is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfgasparin%2Fnfeeasy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfgasparin%2Fnfeeasy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfgasparin%2Fnfeeasy/lists"}