定制 asika/cross-env 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asika/cross-env

最新稳定版本:2.0.3

Composer 安装命令:

composer require asika/cross-env

包简介

Cross platform setting of environment scripts for PHP.

README 文档

README

GitHub Actions Workflow Status Packagist Version Packagist Downloads

Cross platform setting of environment scripts for PHP.

Installation

Install in project

composer require asika/cross-env

Install globally

composer global require asika/cross-env

Usage

Global Install

Just call cross-env:

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

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 https://getcomposer.org/doc/articles/scripts.md

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

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

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

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

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: https://symfony.com/doc/current/components/process.html#usage

统计信息

  • 总下载量: 195.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-13