PHPackages                             asika/cross-env - 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. [CLI &amp; Console](/categories/cli)
4. /
5. asika/cross-env

ActiveLibrary[CLI &amp; Console](/categories/cli)

asika/cross-env
===============

Cross platform setting of environment scripts for PHP.

2.0.3(1y ago)3218.1k↓40.5%11MITPHPPHP &gt;=8.0CI passing

Since Jul 14Pushed 1y agoCompare

[ Source](https://github.com/asika32764/php-cross-env)[ Packagist](https://packagist.org/packages/asika/cross-env)[ RSS](/packages/asika-cross-env/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (5)Versions (16)Used By (1)

PHP cross-env
=============

[](#php-cross-env)

[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/8835e12db5458b10bbff6608982a572a27081c522fcfc3ec1246735e85978dae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173696b6133323736342f7068702d63726f73732d656e762f63692e796d6c3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/8835e12db5458b10bbff6608982a572a27081c522fcfc3ec1246735e85978dae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173696b6133323736342f7068702d63726f73732d656e762f63692e796d6c3f7374796c653d666f722d7468652d6261646765)[![Packagist Version](https://camo.githubusercontent.com/20abfe5763ec28b48c0097029da4d709967b16e6339f80a38e3dd1257aeccf98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6173696b612f63726f73732d656e763f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/asika/cross-env)[![Packagist Downloads](https://camo.githubusercontent.com/576254e605926f36c23f63a5aa5ba3fa2e6d75b23c7181d7bdf9e8fffc27731f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6173696b612f63726f73732d656e763f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/asika/cross-env)

Cross platform setting of environment scripts for PHP.

Installation
------------

[](#installation)

Install in project

```
composer require asika/cross-env
```

Install globally

```
composer global require asika/cross-env
```

Usage
-----

[](#usage)

### Global Install

[](#global-install)

Just call `cross-env`:

```
cross-env APP_ENV=dev TEST_MODE=real php my-code.php
```

### In Project

[](#in-project)

If you install it in project, use composer scripts:

```
{
    ...
    "scripts": {
        "build:dev": "cross-env APP_ENV=dev TEST_MODE=real php my-code.php"
    },
    ...
}
```

Then call it by composer

```
composer build:dev

# OR

composer run build:dev
```

You can also call bin file directly:

```
./vendor/bin/cross-env APP_ENV=dev TEST_MODE=real php my-code.php
```

See

### Alias

[](#alias)

If you have installed node `cross-env` and has a prior order in PATH, you can use `set-env` as an global alias.

### Use `.env` File

[](#use-env-file)

Call `cross-source` to set a file as env vars.

```
cross-source /path/.env php my-code.php
```

Programmatically Call
---------------------

[](#programmatically-call)

If you want to use `cross-env` in your own CLI Application, you can use `CrossEnv\CrossEnv`:

```
$returnCode = \CrossEnv\CrossEnv::runWithCommand('APP_ENV=dev TEST_MODE=real php my-code.php');

// OR

$returnCode = \CrossEnv\CrossEnv::runWithArgs([
    'APP_ENV=dev',
    'TEST_MODE=real',
    'php',
    'my-code.php'
);
```

### Custom Output

[](#custom-output)

Add second argument as a callable.

```
use Symfony\Component\Process\Process;

\CrossEnv\CrossEnv::runWithCommand(
    'APP_ENV=dev TEST_MODE=real php my-code.php',
    function (string $type, string $buffer) {
        if ($type === Process::ERR) {
            // Handle error
        } else {
            // Handle output
        }
    }
);
```

See Symfony/Process:

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance47

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 89.7% 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 ~153 days

Recently: every ~140 days

Total

15

Last Release

398d ago

Major Versions

1.0.9 → 2.0.02023-11-20

PHP version history (3 changes)1.0.0-betaPHP &gt;=7.0

1.0.5PHP &gt;=7.0||&gt;=8.0

2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1639206?v=4)[Simon Asika](/maintainers/asika32764)[@asika32764](https://github.com/asika32764)

---

Top Contributors

[![asika32764](https://avatars.githubusercontent.com/u/1639206?v=4)](https://github.com/asika32764 "asika32764 (35 commits)")[![ricardoboss](https://avatars.githubusercontent.com/u/6266356?v=4)](https://github.com/ricardoboss "ricardoboss (3 commits)")[![mickverm](https://avatars.githubusercontent.com/u/1834265?v=4)](https://github.com/mickverm "mickverm (1 commits)")

---

Tags

clienvcommandcross-env

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/asika-cross-env/health.svg)

```
[![Health](https://phpackages.com/badges/asika-cross-env/health.svg)](https://phpackages.com/packages/asika-cross-env)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[helhum/typo3-console

A reliable and powerful command line interface for TYPO3 CMS

2959.5M255](/packages/helhum-typo3-console)[illuminate/console

The Illuminate Console package.

13046.0M6.5k](/packages/illuminate-console)[automattic/jetpack-changelogger

Jetpack Changelogger tool. Allows for managing changelogs by dropping change files into a changelog directory with each PR.

107.2M176](/packages/automattic-jetpack-changelogger)[whatsdiff/whatsdiff

See what's changed in your project's dependencies

771.2k](/packages/whatsdiff-whatsdiff)

PHPackages © 2026

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