PHPackages                             takuya/php-shell - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. takuya/php-shell

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

takuya/php-shell
================

Safer shell\_exec

1.0.1(6y ago)03GPL-3.0-or-laterPHPPHP &gt;=7.0.0CI failing

Since Apr 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/takuya/php-shell)[ Packagist](https://packagist.org/packages/takuya/php-shell)[ Docs](https://github.com/takuya/php-shell)[ RSS](/packages/takuya-php-shell/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Examples
========

[](#examples)

```
$name = "takuya";
$ret = PHPShell::exec_command('echo $name', ['name'=>$name]);
```

Apparently, `$name` in `'echo $name` looks like php variable, but `$name` is as passed shell env variable.

Compare to escapeshellarg
=========================

[](#compare-to-escapeshellarg)

Quart is unfriendly for debugging.

```
$name = "takuy'a;curl -h ";
$name = escapeshellarg($name); // -> "'takuy'\''a;curl -h '"
```

Long string arguments make code more difficult to read..

```
$url =  escapeshellarg("too long argument ..afasdfasdfasdfasdfawefadf");
$json = escapeshellarg(json_encode($object))
$cmd = 'curl -v -L $url -X POST --data $json';
var_dump($cmd);
```

Using Environment is more simple. And become more clear code what we will do.

```
$env_vars =  ['url'=>$url, 'json'=>$json];
foreach( $env_vars as $k=>$v ){
  putenv("$k=$v");
}
$ret = shell_exec('curl -v -L $url -X POST --data $json');
```

For this reason, this library supports you to pass argument as Environment instead of raw string.

Feature
=======

[](#feature)

Safer calling Shell Command. To avoid escaping Shell arguments , this library using ENV. By using Env instead of escaping, shell command call become slightly safer and simpler to avoid shell command injection.

since
=====

[](#since)

- First release was 2008.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2223d ago

PHP version history (2 changes)1.0PHP &gt;=5.3

1.0.1PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab28766f469b5f1770a63613c5f51d661226e01bd2abd180ad5460e537e7d4fa?d=identicon)[takuya](/maintainers/takuya)

---

Top Contributors

[![takuya](https://avatars.githubusercontent.com/u/55338?v=4)](https://github.com/takuya "takuya (11 commits)")

---

Tags

commandexecshell-exec

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/takuya-php-shell/health.svg)

```
[![Health](https://phpackages.com/badges/takuya-php-shell/health.svg)](https://phpackages.com/packages/takuya-php-shell)
```

###  Alternatives

[pastuhov/php-exec-command

Simple php command executor with param binding.

25205.4k2](/packages/pastuhov-php-exec-command)[cpx/cpx

Run any command from any composer package, even if it's not installed in your project.

40410.9k1](/packages/cpx-cpx)[arara/process

Provides a better API to work with processes on Unix-like systems

16861.7k2](/packages/arara-process)[skywarth/chaotic-schedule

Randomize scheduled command execution time and date intervals

12142.3k](/packages/skywarth-chaotic-schedule)[synolia/sylius-scheduler-command-plugin

Scheduler Command Plugin.

34361.5k](/packages/synolia-sylius-scheduler-command-plugin)[scrumble-nl/laravel-model-ts-type

This package makes it possible to generate TypeScript types based on your models

6984.5k](/packages/scrumble-nl-laravel-model-ts-type)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
