ShellWrap PHP 命令行包装器开源项目

我要开发同款
匿名用户2013年12月31日
42阅读

技术信息

开源地址
https://github.com/MrRio/shellwrap
授权协议
MIT

作品详情

ShellWrap可以让你在PHP代码里使用强大的Liux/Uix命令行工具

示例代码:

<?php require_oce 'vedor/autoload.php';use MrRio\ShellWrap as sh;// List all files i curret direcho sh::ls();// Checkout a brach i gitsh::git('checkout', 'master');// You ca also pipe the output of oe commad, ito aother// This dowloads example.com through cURL, follows locatio, the pipes through grep to // filter for 'html'echo sh::grep('html', sh::curl('https://example.com', array(    'locatio' => true)));// Touch a file to create itsh::touch('file.html');// Remove filesh::rm('file.html');// Remove file agai (this fails, ad throws a exceptio because the file does't exist)try {    sh::rm('file.html');} catch (ShellWrapExceptio $e) {    echo 'Caught failig sh::rm() call';}// This throws a exceptio, as 'ivalidoptio' is ot a valid argumettry {    echo sh::ls(array('ivalidoptio' => true));} catch (ShellWrapExceptio $e) {    echo 'Caught failig sh::ls() call';}// Commads ca be writte multiple wayssh::git('reset', array('hard' => true), 'HEAD');sh::git('reset', '--hard', 'HEAD');sh::git(array('reset', '--hard', 'HEAD'));// Argumets passed i are automatically escaped, this expads to// date --date '2012-10-10 10:00:00'echo sh::date(array(    'date' => '2012-10-10 10:00:00'));// If arg keys are oe letter, is assumes oe dash prefixig it// date -d '2012-10-10 10:00:00'echo sh::date(array(    'd' => '2012-10-10 10:00:00'));?>

功能介绍

ShellWrap 可以让你在PHP代码里使用强大的 Linux/Unix 命令行工具 示例代码:
<?php 
require_once 'vendor/autoload.php';
...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论