engelju/sandbox

测试PHP工作流程组件如何工作

dev-master 2018-03-23 08:45 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:44 UTC


README

这是一个沙盒仓库

在此仓库中测试的内容

  • Git
  • GitHub
  • 多个SSH密钥
  • Composer
  • PHPUnit
  • Packagist
  • Travis-ci
  • Webhooks

徽章

Latest Stable Version Latest Unstable Version Build Status Travis

操作指南

初始设置

  • 安装了通常的先决条件
  • cd htdocs && mkdir helloworld && cd helloworld

Composer

jeng@macbook:/Applications/MAMP/htdocs/helloworld $ composer init

    Welcome to the Composer config generator  

    This command will guide you through creating your composer.json config.

    Package name (<vendor>/<name>) [engelju/helloworld]:

您可以接受默认设置或自定义它,如"yourname/hello"或其他您想要的。完成所有Composer问题,如下所示

    Package name (<vendor>/<name>) [engelju/helloworld]: engelju/helloworld
    Description []: A test packages for composer and github
    Author [Junior Grossi <me@juniorgrossi.com>]: Julie Engel <julie.engel@mail.com>
    Minimum Stability []: dev

定义您的依赖关系。

    Would you like to define your dependencies (require) interactively [yes]? no
    Would you like to define your dev dependencies (require-dev) interactively [yes]? no

    {
        "name": "engelju/composer_github",
        "description": "A test packages for composer and github",
        "authors": [
            {
            "name": "Julie Engel",
            "email": "julie.engel@mail.com"
            }
        ],
        "minimum-stability": "dev",
        "require": {
        }
    }

    Do you confirm generation [yes]? yes

然后我们必须对生成的composer.json进行一些修改,使其看起来像这样

{
    "name": "engelju/composer_github",
    "description": "A test packages for composer and github",
    "authors": [
        {
        "name": "Julie Engel",
        "email": "julie.engel@mail.com"
        }
    ],
    "license": "GPL",
    "autoload": {
        "psr-0": {
            "HelloWorld": "src/"
        }
    },
    "require": {
        "php": ">=5.3.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^4.8@dev"
    },
    "minimum-stability": "dev"
}

我们在这里所做的是添加关于PHP 5.3作为最低要求的(require部分),以及在dev部分要求phpunit,并告诉Composer“自动加载”(使用PSR-0)所有位于"src"目录内的"HelloWorld"命名空间下的文件。

然后您可以执行composer install,它将创建一个vendor目录并在其中安装组件。

文件结构 / 代码

  • mkdir src && mkdir tests
$ tree -L 3
.
├── .gitignore                      --> git ignore file
├── .travis.yml                     --> travis-ci config file
├── LICENSE                         --> first version auto-generated by github
├── README.md                       --> first version auto-generated by github
├── composer.json                   --> composer config file
├── composer.lock                   --> locks the current versions of the dependencies
├── src/                            --> directory where the actual code lies
│   └── HelloWorld/                 --> yay, namespacing
│       └── SayHello.php            --> actual class
├── tests/                          --> directory where our tests lie
│   ├── HelloWorld/                 --> mirroring the code dir sturcture
│   │   └── SayHelloTest.php        --> one test for each class
│   ├── bootstrap.php               --> phpunit bootstrap
│   └── phpunit.xml                 --> phpunit config file
└── vendor/                         --> dependencies, installed with `composer install`
    ├── autoload.php
    ├── bin/
    │   └── phpunit -> ../phpunit/phpunit/phpunit
    ├── composer/
    ├── doctrine/
    ├── phpdocumentor/
    ├── phpspec/
    ├── phpunit/
    ├── sebastian/
    └── symfony/

PHPUnit / 测试

Packagist

Git

  • 分支
  • 提交
  • 远程

多个SSH密钥

有用的文档

GitHub

  • 问题
  • 拉取请求
    • 在自己的项目上工作
    • 为其他项目做出贡献

Webhooks

Travis-CI