Platform.sh Legacy CLI 使用教程
1. 项目的目录结构及介绍
Platform.sh Legacy CLI 项目的目录结构如下:
legacy-cli/
├── bin/
│ └── platform
├── src/
│ ├── Commands/
│ ├── Config/
│ ├── Exceptions/
│ ├── Local/
│ ├── Model/
│ ├── Response/
│ ├── Shell/
│ ├── Utils/
│ └── Client.php
├── templates/
│ └── project/
├── tests/
│ ├── bootstrap.php
│ ├── Commands/
│ ├── Config/
│ ├── Exceptions/
│ ├── Local/
│ ├── Model/
│ ├── Response/
│ ├── Shell/
│ ├── Utils/
│ └── ClientTest.php
├── .gitignore
├── .travis.yml
├── composer.json
├── LICENSE
├── README.md
└── phpunit.xml.dist
目录结构介绍
bin/
: 包含可执行文件platform
,用于启动 CLI。src/
: 包含项目的核心代码,分为多个子目录,如Commands
、Config
、Exceptions
等。templates/
: 包含项目模板文件。tests/
: 包含项目的测试代码。.gitignore
: 指定 Git 忽略的文件和目录。.travis.yml
: Travis CI 配置文件。composer.json
: Composer 依赖管理文件。LICENSE
: 项目许可证。README.md
: 项目说明文档。phpunit.xml.dist
: PHPUnit 测试配置文件。
2. 项目的启动文件介绍
项目的启动文件位于 bin/
目录下的 platform
文件。这个文件是一个可执行的 PHP 脚本,用于启动 Platform.sh Legacy CLI。
启动文件内容概述
#!/usr/bin/env php
<?php
// 引入必要的文件和初始化代码
require __DIR__.'/../src/bootstrap.php';
// 创建应用程序实例并运行
$application = new Platformsh\Cli\Application();
$application->run();
启动文件功能
- 引入必要的文件和初始化代码。
- 创建应用程序实例并运行。
3. 项目的配置文件介绍
项目的配置文件主要包括 composer.json
和 phpunit.xml.dist
。
composer.json
composer.json
文件定义了项目的依赖关系、脚本和其他元数据。
{
"name": "platformsh/legacy-cli",
"description": "Platform.sh CLI",
"license": "MIT",
"require": {
"php": ">=5.5.9",
"symfony/console": "^3.4 || ^4.0",
"symfony/yaml": "^3.4 || ^4.0",
"guzzlehttp/guzzle": "^6.2",
"psr/log": "^1.0",
"monolog/monolog": "^1.22",
"platformsh/config-reader": "^2.1"
},
"autoload": {
"psr-4": {
"Platformsh\\Cli\\": "src/"
}
},
"bin": ["bin/platform"],
"scripts": {
"post-install-cmd": [
"Platformsh\\Cli\\Composer\\ScriptHandler::install"
],
"post-update-cmd": [
"Platformsh\\Cli\\Composer\\ScriptHandler::install"
]
}
}
phpunit.xml.dist
phpunit.xml.dist
文件是 PHPUnit 的配置文件,用于定义测试环境和测试套件。
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Platform.sh CLI Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit