maciejlewandowskii/ifirma-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maciejlewandowskii/ifirma-bundle

Composer 安装命令:

composer require maciejlewandowskii/ifirma-bundle

包简介

iFirma Symfony Bundle for easy invoicing integration.

README 文档

README

Tests Static Analysis Lint Coverage Latest Version PHP Version License

Symfony bundle providing a clean integration with the iFirma API — create and manage invoices, contractors, expenses, payments, employees, and accounting months from your application.

Requirements

  • PHP 8.3+
  • Symfony 7.2+

Installation

composer require maciejlewandowskii/ifirma-bundle

Register the bundle in config/bundles.php (auto-registered if Symfony Flex is used):

return [
    // ...
    maciejlewandowskii\iFirmaApi\IFirmaApiBundle::class => ['all' => true],
];

Configuration

Create config/packages/ifirma_api.yaml:

ifirma_api:
    credentials:
        username:       '%env(IFIRMA_USERNAME)%'
        invoice_key:    '%env(IFIRMA_INVOICE_KEY)%'
        subscriber_key: '%env(IFIRMA_SUBSCRIBER_KEY)%'
        expense_key:    '%env(IFIRMA_EXPENSE_KEY)%'  # optional

Add the corresponding environment variables to your .env:

IFIRMA_USERNAME=your_username
IFIRMA_INVOICE_KEY=your_invoice_key
IFIRMA_SUBSCRIBER_KEY=your_subscriber_key
IFIRMA_EXPENSE_KEY=your_expense_key

Usage

Inject iFirmaApi (or any individual service) wherever you need it:

use maciejlewandowskii\iFirmaApi\iFirmaApi;

class YourService
{
    public function __construct(private readonly iFirmaApi $iFirma) {}

    public function createInvoice(): void
    {
        $invoice = new InvoiceRequest(/* ... */);
        $response = $this->iFirma->invoiceService->create($invoice);
    }
}

Available services

Service Description
invoiceService Create, update, send, download invoices
contractorService Manage contractors
expenseService Add VAT and other expenses
paymentService Record payments
orderService Handle orders
accountingMonthService Open / close accounting months
vatDictionaryService Fetch VAT rate dictionaries
employeeService Manage employees

Entity synchronization

Implement HasIFirmaIntegration on your Doctrine entity and use the SynchronizationManager to automatically push local entities to iFirma:

use maciejlewandowskii\iFirmaApi\Synchronization\HasIFirmaIntegration;

class Invoice implements HasIFirmaIntegration
{
    // implement required methods
}

The bundle dispatches PreSyncEvent and PostSyncEvent so you can hook into the sync lifecycle. A SyncEntitiesCommand and an async SyncEntityMessage / SyncEntityMessageHandler are also included for batch or queue-based synchronization.

Standalone (without Symfony)

use maciejlewandowskii\iFirmaApi\iFirmaApiFactory;

$api = iFirmaApiFactory::create(
    username: 'your_username',
    invoiceKeyHex: 'your_invoice_key',
    subscriberKeyHex: 'your_subscriber_key',
);

$api->invoiceService->create(/* ... */);

Development

Running tests

# Unit tests (no credentials needed)
vendor/bin/phpunit --testsuite Unit

# Integration tests (require real iFirma credentials in .env.test.local)
vendor/bin/phpunit --testsuite Integration

Copy .env.test to .env.test.local and fill in your credentials to run integration tests:

IFIRMA_USERNAME=your_username
IFIRMA_INVOICE_KEY=your_invoice_key
IFIRMA_SUBSCRIBER_KEY=your_subscriber_key
IFIRMA_EXPENSE_KEY=your_expense_key# optional

Code coverage

Coverage is enforced at 95% minimum on every CI run (PHP 8.3 and 8.4). The full report is uploaded to Codecov on each push to main.

Code style & static analysis

# Fix code style
vendor/bin/php-cs-fixer fix

# Apply Rector refactors
vendor/bin/rector process

# Run PHPStan (level 10)
vendor/bin/phpstan analyse

All three are enforced in CI via the Lint and Static Analysis workflows. The security job also runs composer audit and composer-require-checker on every push.

License

MIT — see LICENSE.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固