ismaildasci/laravel-sapb1-toolkit
Composer 安装命令:
composer require ismaildasci/laravel-sapb1-toolkit
包简介
Complete business logic toolkit for SAP Business One Service Layer - Eloquent-like ORM, Actions, Builders, DTOs, Caching, Change Tracking, and Local Database Sync
关键字:
README 文档
README
A complete business logic toolkit for SAP Business One Service Layer integration in Laravel. Built on top of laravel-sapb1.
Features
| Component | Count | Description |
|---|---|---|
| Models | 54 | Eloquent-like ORM for SAP B1 entities |
| Actions | 110 | CRUD operations for all SAP B1 entities |
| Builders | 122+ | Fluent document construction |
| DTOs | 145+ | Type-safe data transfer objects |
| Services | 17 | Business logic orchestration |
| Enums | 36 | SAP B1 constants and status codes |
| Commands | 7 | Artisan CLI commands |
| Cache | 2 | Priority-based caching system |
Modules: Sales, Purchase, Inventory, Finance, Business Partner, Production, HR, Admin, Service
Key Capabilities
- Eloquent-like ORM - Query SAP B1 entities with familiar Laravel syntax
- UDF Support - Read/write User Defined Fields on any entity
- Local Caching - Priority-based cache with entity-level configuration
- Change Tracking - Polling-based change detection for SAP entities
- Local Database Sync - Sync SAP data to local database with soft deletes
Requirements
- PHP 8.4+
- Laravel 11.x or 12.x
- laravel-sapb1 ^1.0
Installation
composer require ismaildasci/laravel-sapb1-toolkit
php artisan vendor:publish --tag="sapb1-toolkit-config"
Quick Start
Eloquent-like Models
use SapB1\Toolkit\Models\Sales\Order; $orders = Order::where('DocTotal', '>', 1000) ->where('DocumentStatus', 'bost_Open') ->orderBy('DocDate', 'desc') ->with('partner') ->get(); $order = Order::create([ 'CardCode' => 'C001', 'DocumentLines' => [ ['ItemCode' => 'ITEM001', 'Quantity' => 10, 'Price' => 100], ], ]);
Actions
use SapB1\Toolkit\Actions\Sales\OrderAction; $orderAction = app(OrderAction::class); $order = $orderAction->create([ 'CardCode' => 'C001', 'DocumentLines' => [ ['ItemCode' => 'ITEM001', 'Quantity' => 10, 'Price' => 100], ], ]); $orderAction->close(123);
Builders
use SapB1\Toolkit\Builders\Sales\OrderBuilder; $data = OrderBuilder::create() ->cardCode('C001') ->docDate('2024-01-15') ->addLine(fn ($line) => $line ->itemCode('ITEM001') ->quantity(10) ->price(100) ) ->build();
Services
use SapB1\Toolkit\Services\DocumentFlowService; $flow = app(DocumentFlowService::class); $invoice = $flow->orderToInvoice(123); $delivery = $flow->orderToDelivery(123);
UDF Support (v2.4+)
use SapB1\Toolkit\Models\Sales\Order; $order = Order::find(123); // Read UDFs $value = $order->getUdf('CustomField'); $allUdfs = $order->getUdfs(); // Write UDFs $order->setUdf('CustomField', 'value'); $order->save(); // Builder support $data = OrderBuilder::create() ->cardCode('C001') ->udf('CustomField', 'value') ->build();
Local Cache (v2.5+)
use SapB1\Toolkit\Models\Inventory\Item; // Query-level cache control $item = Item::cache()->find('A001'); // Enable with default TTL $item = Item::cache(600)->find('A001'); // 10 minute TTL $item = Item::noCache()->find('A001'); // Disable cache // Flush cache Item::flushCache(); Item::forgetCached('A001');
Change Tracking (v2.6+)
use SapB1\Toolkit\ChangeTracking\ChangeTracker; $tracker = ChangeTracker::for('Orders') ->primaryKey('DocEntry') ->detectCreated(true) ->detectUpdated(true); $changes = $tracker->poll(); foreach ($changes as $change) { if ($change->isCreated()) { // Handle new order } }
Local Database Sync (v2.7+)
# Create migrations for entities you want to sync php artisan sapb1:sync-setup Items BusinessPartners Orders # Run migrations php artisan migrate # Sync data php artisan sapb1:sync Items # Incremental sync php artisan sapb1:sync Items --full # Full sync with delete detection php artisan sapb1:sync-status # Check sync status
use SapB1\Toolkit\Sync\LocalSyncService; $syncService = app(LocalSyncService::class); // Sync to local database $result = $syncService->sync('Items'); // SyncResult { created: 10, updated: 140, deleted: 0, duration: 1.23s } // Full sync with soft delete detection $result = $syncService->fullSyncWithDeletes('Items'); // Scheduler integration $schedule->command('sapb1:sync Items')->hourly(); $schedule->command('sapb1:sync Items --full')->weekly();
Artisan Commands
| Command | Description |
|---|---|
sapb1:sync {entity} |
Sync SAP data to local database |
sapb1:sync-setup {entities} |
Create sync migrations |
sapb1:sync-status |
Show sync status |
sapb1:watch {entity} |
Watch for entity changes |
sapb1:cache |
Manage entity cache |
sapb1:test-connection |
Test SAP B1 connection |
sapb1:generate |
Generate toolkit components |
Documentation
| Topic | Description |
|---|---|
| Installation | Setup and configuration |
| Models | Eloquent-like ORM |
| Actions | CRUD operations |
| Builders | Fluent document builders |
| DTOs | Data transfer objects |
| Services | Business logic |
| Enums | SAP B1 constants |
| Validation | Laravel validation rules |
| Exceptions | Error handling |
Directory Structure
src/
├── Actions/ # CRUD operations (110 files)
├── Builders/ # Fluent builders (122+ files)
├── DTOs/ # Data Transfer Objects (145+ files)
├── Models/ # Eloquent-like ORM (54 files)
├── Services/ # Business logic (17 files)
├── Enums/ # SAP B1 constants (36 files)
├── Cache/ # Caching infrastructure
├── ChangeTracking/ # Change detection system
├── Sync/ # Local database sync
├── Events/ # Document lifecycle events
├── Exceptions/ # Domain-specific exceptions
├── Rules/ # Laravel validation rules
├── Casts/ # Attribute casts
└── Commands/ # Artisan commands (7 files)
Testing
composer test # Run tests composer analyse # Static analysis composer format # Code formatting
Changelog
See CHANGELOG.md for version history.
Contributing
See CONTRIBUTING.md for guidelines.
Security
Report vulnerabilities via security policy.
License
MIT License. See LICENSE.md for details.
Author: İsmail Daşcı
ismaildasci/laravel-sapb1-toolkit 适用场景与选型建议
ismaildasci/laravel-sapb1-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「cache」 「toolkit」 「sync」 「laravel」 「dto」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ismaildasci/laravel-sapb1-toolkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ismaildasci/laravel-sapb1-toolkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ismaildasci/laravel-sapb1-toolkit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Kinikit - PHP Application development framework MVC component
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
Laravel 5 - Repositories to the database layer
Symfony2 Bundle that adds basic user account entity and city/state/country setup as well
PeskyORM - annoying ORM that contains tons of exceptions and throws them when anything goes wrong
统计信息
- 总下载量: 49
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-03