php-prefixer/php-prefixer-cli

PHP-Prefixer 服务的命令行工具。

0.0.7 2022-12-03 19:24 UTC

This package is auto-updated.

Last update: 2024-09-30 01:30:17 UTC


README

PHP-Prefixer

MIT License

PHP-Prefixer 服务的命令行工具。

博客文章公告新 PHP-Prefixer CLI:从终端添加前缀

PHP-Prefixer 服务提供了一个命令行(CLI)工具,用于在本地使用服务并从您的工作站处理项目源代码。

该命令通过 REST API 调用 PHP-Prefixer 服务,提交项目源代码,应用前缀,等待并下载结果。

PHP-Prefixer 是一个云服务,用于将 PHP 前缀应用于命名空间、函数、辅助函数、特性、接口等。从 Composer 项目和一组依赖项开始,一次生成所有库文件的一致前缀代码库。

给定以下示例类声明

namespace Carbon;

use Carbon\Exceptions\InvalidDateException;
use DateInterval;
use Symfony\Component\Translation;

class Carbon extends DateTime
{
    const NO_ZERO_DIFF = 01;
...

关联的前缀类声明,具有新的唯一命名空间 ACME

namespace ACME\Carbon;

use ACME\Carbon\Exceptions\InvalidDateException;
use DateInterval;
use ACME\Symfony\Component\Translation;

class Carbon extends DateTime
{
    const NO_ZERO_DIFF = 01;
...

如何安装 CLI?

您可以使用两种方式安装 CLI

1. 如何安装 PHAR CLI

首选的安装方法是使用 PHP Prefixer CLI PHAR。您可以从最新的 Github 发布 下载最新的 PHAR。下载后,将其复制到本地路径上的目录中,并赋予执行权限以运行以下命令。

2. 通过 Composer 安装

或者,您可以使用 Composer 全局安装 PHP-Prefixer CLI

composer global require php-prefixer/php-prefixer-cli

源代码在此处可用: https://github.com/PHP-Prefixer/php-prefixer-cli

用法

要使用 CLI,您必须在 PHP-Prefixer 上创建账户,并使用 composer.json 中的前缀定义准备您的项目。

在使用命令行之前,我们建议您查看此处提供的文档和指南: https://php-prefixer.com/docs/

CLI 需要四个参数才能运行,并且可以接收一个额外的参数用于 GitHub 集成

# Sample command-line
./php-prefixer-cli prefix \
\
    /sample/acme_project \
\
    /output/prefixed_project \
\
    "789|1234567890123456789012345678901234567890" \
\
    123456 \
\
    --github-access-token=1234567890123456789012345678901234567890

环境变量

CLI 支持在项目的 .env 文件中定义参数作为环境变量。

# PHP Prefixer CLI - Sample .env

# Note: the .env file must be located in the php-prefixer-cli.phar directory

# Source Directory: The project source directory
SOURCE_DIRECTORY="/sample/acme_project"

# Target Directory: The target directory where the results are stored
TARGET_DIRECTORY="/output/prefixed_project"

# Personal Access Token: The personal access token, generated on PHP-Prefixer Settings
PERSONAL_ACCESS_TOKEN="789|1234567890123456789012345678901234567890"

# Project ID: The identification of the configured project on PHP-Prefixer Projects
PROJECT_ID="123456"

# GitHub Access Token:  An optional GitHub token to access composer.json dependencies that are managed in private repositories.
GITHUB_ACCESS_TOKEN="1234567890123456789012345678901234567890"

文档

命令行开发

如果您想自定义命令行或帮助我们进行开发,请按照以下步骤操作

步骤 1:克隆项目

git clone https://github.com/php-prefixer/php-prefixer-cli

步骤 2:转到项目目录

cd php-prefixer-cli

步骤 3:安装依赖项

composer update

步骤 4:构建 PHAR

./php-prefixer-cli app:build

步骤 5:要运行测试,请执行以下命令

phpunit

路线图 / 想法

此路线图可能随时更改,并且仅应作为有关未来版本的一般指南使用。只要版本、功能或应用程序尚未发布,日期是估计的,可能被更改。

  • 用于排除 ZIP 目录的参数,--exclude

贡献

当前的命令行接口是用于在PHP代码前添加前缀的起点。如果您想改进当前的命令行,贡献总是受欢迎的!

有关如何开始的详细信息,请参阅CONTRIBUTING.md

安全

如果您在此包中发现安全漏洞,请通过电子邮件发送至Anibal Sanchez(team@php-prefixer.com)。我们将及时处理所有安全漏洞。

许可证

MIT

作者