bolk/php-applescript-ffi
Composer 安装命令:
composer require bolk/php-applescript-ffi
包简介
Run AppleScript on macOS from PHP via FFI and the Open Scripting Architecture.
README 文档
README
Run AppleScript on macOS from PHP through the native Open Scripting Architecture exposed via FFI.
Requirements
- macOS
- PHP 8.3+
ext-ffi- FFI must be enabled in php.ini:
ffi.enable=trueorffi.enable=preload(when running from CLI). Valuestrueand1are both accepted.
Installation
composer require bolk/php-applescript-ffi
Usage
<?php use Bolk\AppleScript\AppleScript; $appleScript = new AppleScript(); // Execute and get the result as a string. echo $appleScript->execute('return (current date) as string'); // current date // Execute without caring about the result. $appleScript->run('say "Hello from PHP"');
Runtime Check
Use AppleScript::isSupported() to check the current runtime prerequisites without throwing exceptions. This is handy for graceful degradation, but it does not guarantee that the native macOS bindings will initialize successfully on the first execution call:
if (AppleScript::isSupported()) { $appleScript = new AppleScript(); $appleScript->run('say "Hello from PHP"'); }
You should still be prepared to catch FfiUnavailableException when calling execute() or run().
Security Warning
Never concatenate untrusted user input directly into your AppleScript strings.
AppleScript has access to the underlying system and can execute shell commands (do shell script). Allowing arbitrary user input to be executed as AppleScript is equivalent to a Remote Code Execution (RCE) vulnerability. Always validate and sanitize any variables passed into your scripts.
Exceptions
UnsupportedPlatformException— not running on macOS.FfiUnavailableException— FFI extension is missing, disabled (ffi.enable=false), restricted to preload while not in CLI, or the native macOS FFI bindings fail to initialize.ExecutionException— AppleScript execution failed (syntax error, runtime error). The message contains the AppleScript error text when available.
Testing
composer test # all tests composer test:unit # unit tests only composer test:integration # integration tests (requires macOS with FFI)
bolk/php-applescript-ffi 适用场景与选型建议
bolk/php-applescript-ffi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bolk/php-applescript-ffi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bolk/php-applescript-ffi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-19