baja-foundry/flysystem-filecabinet
Composer 安装命令:
composer require baja-foundry/flysystem-filecabinet
包简介
NetSuite FileCabinet adapter for Flysystem with Laravel support
README 文档
README
A Laravel-ready Flysystem adapter for NetSuite's FileCabinet, enabling seamless file operations through NetSuite's REST API with OAuth 1.0 authentication.
Features
- ✅ Full Flysystem v3 compatibility - All standard file operations supported
- 🔐 OAuth 1.0 authentication - Secure NetSuite REST API integration
- 🚀 Laravel auto-discovery - Zero-configuration Laravel integration
- 📁 Complete file operations - Read, write, delete, copy, move, list
- 🗂️ Directory management - Create, delete, and navigate folders
- 🔍 Connection testing - Built-in connectivity verification
- 🛡️ Error handling - Comprehensive exception handling
- 📊 File metadata - Size, mime type, last modified date
- ✨ Production ready - Thoroughly tested with PHPUnit
Quick Start
Installation
composer require baja-foundry/flysystem-filecabinet:^1.0.0-beta.1
Laravel Configuration
Add to config/filesystems.php:
'netsuite_filecabinet' => [ 'driver' => 'netsuite_filecabinet', 'base_url' => env('NETSUITE_BASE_URL'), 'consumer_key' => env('NETSUITE_CONSUMER_KEY'), 'consumer_secret' => env('NETSUITE_CONSUMER_SECRET'), 'token_id' => env('NETSUITE_TOKEN_ID'), 'token_secret' => env('NETSUITE_TOKEN_SECRET'), 'realm' => env('NETSUITE_REALM'), ],
Test Connection
php artisan tinker
$disk = Storage::disk('netsuite_filecabinet'); $result = $disk->getAdapter()->testConnection(); dump($result); // Should show success: true
Documentation
- 📋 Installation Guide - Complete Laravel setup and testing with artisan tinker
- 🔌 Connection Testing - Verify NetSuite connectivity and troubleshoot issues
- 🧪 Live Testing Guide - Run tests against real NetSuite environments
Requirements
- PHP: ^8.2
- Laravel: ^10.0 | ^11.0 (optional, works standalone)
- Flysystem: ^3.30
- NetSuite: REST API access with valid OAuth credentials
Supported Operations
| Operation | Method | Description |
|---|---|---|
| Files | ||
| Read | get(), readStream() |
Download file contents |
| Write | put(), putFileAs() |
Upload files to NetSuite |
| Delete | delete() |
Remove files |
| Copy | copy() |
Duplicate files |
| Move | move() |
Relocate files |
| Exists | exists() |
Check file existence |
| Metadata | ||
| Size | size() |
Get file size in bytes |
| MIME Type | mimeType() |
Detect content type |
| Modified | lastModified() |
Get modification timestamp |
| Directories | ||
| Create | makeDirectory() |
Create folders |
| Delete | deleteDirectory() |
Remove folders (recursive) |
| List | files(), allFiles() |
List directory contents |
| Connectivity | ||
| Test | testConnection() |
Verify API access |
Basic Usage
Laravel
use Illuminate\Support\Facades\Storage; $disk = Storage::disk('netsuite_filecabinet'); // Upload a file $disk->put('documents/report.pdf', $pdfContent); // Download a file $content = $disk->get('documents/report.pdf'); // Check if file exists if ($disk->exists('documents/report.pdf')) { echo "File exists!"; } // List files $files = $disk->files('documents');
Standalone PHP
use BajaFoundry\NetSuite\Flysystem\Adapter\NetSuiteFileCabinetAdapter; use BajaFoundry\NetSuite\Flysystem\Client\NetSuiteClient; use League\Flysystem\Filesystem; $client = new NetSuiteClient([ 'base_url' => 'https://account.suitetalk.api.netsuite.com', 'consumer_key' => 'your_consumer_key', 'consumer_secret' => 'your_consumer_secret', 'token_id' => 'your_token_id', 'token_secret' => 'your_token_secret', 'realm' => 'your_account_id', ]); $adapter = new NetSuiteFileCabinetAdapter($client); $filesystem = new Filesystem($adapter); // Test connection $result = $adapter->testConnection(); if ($result['success']) { $filesystem->write('hello.txt', 'Hello NetSuite!'); }
NetSuite Setup Requirements
You'll need the following from your NetSuite account:
- Integration Record with Consumer Key & Secret
- Access Token Record with Token ID & Secret
- Account ID for realm parameter
- Proper permissions for FileCabinet and SuiteQL access
See INSTALL.md for detailed setup instructions.
Advanced Usage
Custom Root Folder
Restrict operations to a specific NetSuite folder:
$adapter = new NetSuiteFileCabinetAdapter($client, 'folder-id-123');
Path Prefixing
Add automatic path prefixes:
$adapter = new NetSuiteFileCabinetAdapter($client, '', 'uploads/'); // All operations will be prefixed with 'uploads/'
Error Handling
use NetSuite\Flysystem\Exceptions\NetSuiteException; use League\Flysystem\UnableToReadFile; try { $content = $disk->get('nonexistent.txt'); } catch (UnableToReadFile $e) { echo "File not found: " . $e->getMessage(); } catch (NetSuiteException $e) { echo "NetSuite API error: " . $e->getMessage(); }
Testing
The package includes comprehensive testing at multiple levels:
Mock-Based Tests (Fast, No NetSuite Required)
# Run all mock-based tests composer test # Run specific test suites composer test-unit # Unit tests only composer test-integration # Integration tests only # With coverage composer test-coverage
Live NetSuite Tests (Requires Real NetSuite Access)
# Run live tests against real NetSuite composer test-live # Live tests with coverage composer test-live-coverage # Run all tests (mock + live) composer test-all
Code Quality
# Static analysis composer phpstan # Code style checks composer phpcs # Fix code style composer phpcbf
Test Statistics
- 31 Mock-Based Tests - Fast execution, no credentials required
- 28 Live Tests - Real NetSuite environment validation
- 96.7% Success Rate - Reliable and thoroughly tested
- Automatic Cleanup - Live tests clean up after themselves
See LIVE_TESTING.md for detailed live testing setup and configuration.
Development
Local Setup
git clone https://github.com/your-repo/netsuite-flysystem-filecabinet.git
cd netsuite-flysystem-filecabinet
composer install
Architecture
src/
├── Adapter/
│ └── NetSuiteFileCabinetAdapter.php # Main Flysystem adapter
├── Client/
│ └── NetSuiteClient.php # OAuth HTTP client
├── Exceptions/
│ ├── NetSuiteException.php # Base exception
│ └── FileNotFoundException.php # File-specific errors
└── Laravel/
└── NetSuiteFileCabinetServiceProvider.php # Laravel integration
Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| Authentication failed | Verify OAuth credentials and NetSuite permissions |
| Driver not found | Check Laravel service provider registration |
| Connection timeout | Increase timeout in configuration |
| Permission denied | Ensure NetSuite role has FileCabinet access |
See CONNECTION_TESTING.md for detailed troubleshooting.
Contributing
We welcome contributions! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for new features
- Ensure all tests pass
- Submit a Pull Request
Development Guidelines
- Follow PSR-12 coding standards
- Add PHPDoc comments
- Write tests for new features
- Update documentation as needed
Security
- Never commit NetSuite credentials to version control
- Use environment variables for sensitive configuration
- Regularly rotate OAuth tokens
- Monitor API usage for unauthorized access
License
This package is open-sourced software licensed under the MIT license.
Credits
- Built on Flysystem by The League of Extraordinary Packages
- Inspired by the Laravel ecosystem and NetSuite's FileCabinet system
- OAuth 1.0 implementation following NetSuite's SuiteTalk specifications
Support
- Documentation: INSTALL.md | CONNECTION_TESTING.md | LIVE_TESTING.md
- Issues: GitHub Issues
- NetSuite Docs: SuiteTalk REST Web Services
Made with ❤️ for the Laravel and NetSuite communities.
baja-foundry/flysystem-filecabinet 适用场景与选型建议
baja-foundry/flysystem-filecabinet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「filesystem」 「laravel」 「Flysystem」 「netsuite」 「FileCabinet」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 baja-foundry/flysystem-filecabinet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 baja-foundry/flysystem-filecabinet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 baja-foundry/flysystem-filecabinet 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A PHP class providing static methods for reading, writing, copying, moving, and deleting files and directories, MIME type detection, image size detection, and file permission management
Backblaze B2 Cloud Storage for Laravel 5. Original by Paul Olthof (@hpolthof) continued by @bringyourownideas
Virtual Filesystem Storage Adapter for Laravel
The flysystem adapter for yandex disk rest api.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-23