innmind/virtual-machine 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

innmind/virtual-machine

Composer 安装命令:

composer require innmind/virtual-machine

包简介

README 文档

README

Build Status codecov Type Coverage

Small abstraction on top of innmind/cli to manage processes and filesystem within the context of a project.

This is intended for CLI applications where the binary must be run within the context of the project.

Note: do not use this package for CLI tools that you can run from anywhere in your operating system.

Installation

composer require innmind/virtual-machine

Usage

# some/binary.php

use Innmind\CLI\{
    Main,
    Environment,
};
use Innmind\OperatingSystem\OperatingSystem;
use Innmind\VirtualMachine\{
    VirtualMachine,
    Command,
};
use Innmind\Server\Status;
use Innmind\Server\Control;
use Innmind\Immutable\Set;

new class extends Main
{
    protected function main(Environment $env, OperatingSystem $os): void
    {
        $vm = VirtualMachine::of($env, $os);

        if ($env->workingDirectory()->toString() !== __DIR__.'/') {
            throw new \Exception('binary.php must me executed from within the "some/" directory')
        }

        // all required paths are resolved from the working directory so you don't
        // have to do the resolution yourself, and it's safe to require a file
        // from anywhere within your app
        $vm->filesystem()->require(Path::of('other_file.php'));

        // this is similar to $os->status()->processes()->all() but here the set
        // will only contain processes that are running whithin the working
        // directory for the same "binary.php" bin
        /** @var Set<Status\Server\Process> */
        $processes = $vm->processes()->all();

        // this is a shortcut to start a new process with the command
        // "php binary.php 'some-command'" started within the same working
        // directory. So you don't have to repeat the the binary name and
        // specify the working directory. The process is started in the foreground.
        /** @var Control\Server\Process */
        $process = $vm->processes()->execute(Command::of('some-command'));

        // Same as the line above except the process is started in the background
        $vm->processes()->daemon(Command::of('some-daemon'));
    }
}

Note: of course you can name your bin file anyway you want, not just binary.php.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固