Initial Commit

Fixed typos

Update README.md

Ninja 5.6 test

Update README.md

Update CONTRIBUTING.md

Update CONTRIBUTING.md

update skeleton project

Switched to composer require

Remove version from composer require

Composer detects the latest stable version (only 0.x should specify the version)
http://blog.doh.ms/2014/10/13/installing-composer-packages/

Update README.md

Fix duplicate require-dev entry

Update LICENSE to use Markdown

Update LICENSE.md link

Add .gitattributes file

Fix documentation

Fix typo

Remove extra newline

Added php_analyzer: true to scritunizer

Rename scrutinizer.yml to .scrutinizer.yml

updated scrutinizer reference

consistent headlines in CHANGELOG.md

This fits also more into the style from http://keepachangelog.com/

Harmonize package variables

fix syntax in CHANGELOG.md

Readme: use relative paths to CONTRIBUTING.md and contributors

new year

update copyright year

remove duplicate field

the `:author_website` option was listed twice

Add a security section

Add Ocular as dev-dependency, fixes HHVM issues too apparently

Updated package name to be able to submit to Packagist

Reverting

Typo in README.md

Update SkeletonClass.php

Added php 7.0 and allow it to fail

Added php 7.0 and allow it to fail

Removed PHP 5.3

Removed --dev flag

According to Travis-Ci, "You are using the deprecated option "dev". Dev packages are installed by default now."

travis: PHP 7.0 nightly added

simplifies configuration

This removes a few settings that had no effect anymore.

Update CONTRIBUTING.md

Not everyone may be familiar with the term (or the details of) "squashing." A link to the git documentation would be helpful in this case.

Added editor configuration

Add use of Composer scripts like 'composer test'

Update `composer test` to simply use `phpunit`

Encourage developers to read the change log

docs(testing): Update testing to use composer test

https://getcomposer.org/doc/articles/scripts.md#writing-custom-commands

Added end_of_line & some more info about this file

> It is acceptable and often preferred to leave certain EditorConfig properties unspecified. For example [...] if a property is not standardized in your project (end_of_line for example), it may be best to leave it blank.

http://editorconfig.org/#file-format-details

I added ``end_of_line`` nonetheless, as I think there is an agreement to always use ``lf``.

[Travis] Test lowest version dependencies

Use Packagist Release badge instead of GH release

Because most repos don't do releases, they just tag their revisons. Which suffices for Composer/Packagist - but the current badge would simply state "Release: None"...

Alternatively the GH Tag badge could be used instead.

Do not call ocular in PHP 7.0 and HHVM

We cannot be dead certain that those support code coverage, so they would break the Scrutinizer build the following message "Scrutinizer was notified that the tests failed." even though all builds succeeded.

At the moment HHVM seems to work, excluding it nonetheless.
Also now it correlates with three runs configured in 13bd2abaeb/.scrutinizer.yml (L23)

use composer test

Moved all links to the bottom of README.md

Forgot to update image alt text

Switch to local phpunit

This ensures consistency across platforms and testing by using the same version of PHPUnit, rather than whatever is globally installed by the system.

Revert `composer test` in composer.json

First, composer will push its bin to the top of the $PATH when running composer scripts, so this isn't strictly necessary. Secondly, using `/` will fail on Windows. This reverts one of the changes previously made in 54f6cbc606.

Add sudo false to Travis config

Add comment about sudo false Travis config

Added CONDUCT.md

Many people are great developers, but awful awful human beings. This will remind their robot brains how to human with other humans in a way that doesn't make one of those humans sad or really angry.

Mention CONDUCT.md in the README

Added disclaimer to code of conduct application

Update CONDUCT.md

use `:vendor` placeholder

to make the package more useful for general use, replace references to
`thephpleague` and `league` with `:vendor`.

Added PSR2 check

Bump minimum PHP version to 5.4

Disallow PHP 7 failures

PHP 7 is now stable and Travis is using these stable builds for testing

Use "Keep a CHANGELOG" principles

See http://keepachangelog.com/

Add "type" to composer.json

travis: drop PHP 5.4

composer: bump to PHP 5.5, allow PHP 7 in safe way

Resolved issue#67

Removed blank lines

Update copyright year

Add .styleci.yml

Removed redundant Test namespace

Allow PHPUnit v5

Prefer dist + cache for Travis builds

To speed up builds

added composer script for psr2 formatting

Enhancement: Keep packages sorted

Update php version required

In order to require only supported php version,
update minimum php version required from 5.5 to 5.6.

travis: bump min version to PHP 5.6, add PHP 7.1

Min version is PHP 5.6, see composer: ad403d7a63/composer.json (L20)
Also PHP 7.1 is available on Travis

Create PULL_REQUEST_TEMPLATE.md

Create ISSUE_TEMPLATE.md

Use PHP-specific examples in Issue template

Updated CoC to CC 1.4

Added coc contact email address

Added script prefill.php to replace all :variables

Added script prefill.php to replace all :variables

Use PHP-specific examples

Add PHP Codesniffer as development dependency

Add Composer scripts "check-codestyle" & "fix-codestyle"

Adjust Contribution guide

Ignore errors and warnings in PHPCS

Refs: https://github.com/thephpleague/skeleton/pull/41#issuecomment-104071697

Thanks to @gsherwood

Fix indentation

Replace check-codestyle & fix-codestyle with check-style & fix-style respecively

set the author email as the contact in the CONDUCT file

add the xml.dist extesion to the prefil script

Use phar version of ocular

It's impossible to install the latest version of Guzzle due
ocular (used to upload code coverage) depending on guzzlehttp/guzzle ~3.0.

See https://github.com/scrutinizer-ci/ocular/blob/master/composer.json

Closes #95

Inspired by https://github.com/Ocramius/ProxyManager/blob/master/.travis.coverage.sh

Add .travis.coverage.sh to gitattributes

Don't use separate file for uploading code coverage

Remove .travis.codecoverage.sh from git attributes

Remove useless items from PR checklist

These rules will be checked in the Travis build.

Add note about CI

Fix #87 | "docs" entry in .gitignore?

Remove docs directory out of .gitignore and locate it in .gitaatributes

Fix typo

Add missing word

Adding in recommended directory structure

Update README.md

Update year in LICENSE.md

Fix tests directory name

Because almost all League projects uses `tests/`, including this skeleton.

Update README.md

Remove Composer self-updating from .travis.yml

It is done automatically by Travis.

Revert "Remove Composer self-updating from .travis.yml"

Revert "Revert "Remove Composer self-updating from .travis.yml""

Fix minor grammar error in code of conduct

Replace placeholders in tests as well

trailing comma not allowed

put array back the way it was

Update composer.json

Just to accept the latest PHPUnit version

Fix tests on PHP 5.6 & HHVM

Rename CONDUCT.md to CODE_OF_CONDUCT.md

GitHub looks for [CODE_OF_CONDUCT.md](https://help.github.com/articles/adding-a-code-of-conduct-to-your-project/)

fix capitalization

test on 7.2

7.2 is released now, so let's test it.

Spelling mistake?

not my strong area but I think this should be `practices` not `practises`

change the year in LICENSE.md

Remove TAP adapter

Added a phpcs.xml.dist file

Add phpcs to gitignore and gitattributes file

Use new PHP analysis engine

Update travis to test on PHP7.3

init 1
This commit is contained in:
Yoann Celton 2013-08-07 18:33:05 +01:00 committed by Aryess
commit 623db82a57
19 changed files with 664 additions and 0 deletions

15
.editorconfig Normal file
View File

@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

12
.gitattributes vendored Normal file
View File

@ -0,0 +1,12 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
/docs export-ignore

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
build
composer.lock
vendor
phpcs.xml
phpunit.xml

31
.scrutinizer.yml Normal file
View File

@ -0,0 +1,31 @@
build:
nodes:
analysis:
project_setup:
override: true
tests:
override: [php-scrutinizer-run]
filter:
excluded_paths: [tests/*]
checks:
php:
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 600
runs: 3

1
.styleci.yml Normal file
View File

@ -0,0 +1 @@
preset: psr2

38
.travis.yml Normal file
View File

@ -0,0 +1,38 @@
dist: trusty
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- hhvm
# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false
## Cache composer
cache:
directories:
- $HOME/.composer/cache
matrix:
include:
- php: 5.6
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
before_script:
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
script:
- vendor/bin/phpcs --standard=psr2 src/
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
after_script:
- |
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' && "$TRAVIS_PHP_VERSION" != '7.0' ]]; then
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi

22
CHANGELOG.md Normal file
View File

@ -0,0 +1,22 @@
# Changelog
All notable changes to `:package_name` will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## NEXT - YYYY-MM-DD
### Added
- Nothing
### Deprecated
- Nothing
### Fixed
- Nothing
### Removed
- Nothing
### Security
- Nothing

74
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,74 @@
# Contributor Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at `:author_email`. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

32
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,32 @@
# Contributing
Contributions are **welcome** and will be fully **credited**.
We accept contributions via Pull Requests on [Github](https://github.com/:vendor/:package_name).
## Pull Requests
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``.
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **Create feature branches** - Don't ask us to pull from your master branch.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
## Running Tests
``` bash
$ composer test
```
**Happy coding**!

27
ISSUE_TEMPLATE.md Normal file
View File

@ -0,0 +1,27 @@
<!-- Provide a general summary of the issue in the Title above -->
## Detailed description
Provide a detailed description of the change or addition you are proposing.
Make it clear if the issue is a bug, an enhancement or just a question.
## Context
Why is this change important to you? How would you use it?
How can it benefit other users?
## Possible implementation
Not obligatory, but suggest an idea for implementing addition or change.
## Your environment
Include as many relevant details about the environment you experienced the bug in and how to reproduce it.
* Version used (e.g. PHP 5.6, HHVM 3):
* Operating system and version (e.g. Ubuntu 16.04, Windows 7):
* Link to your project:
* ...
* ...

21
LICENSE.md Normal file
View File

@ -0,0 +1,21 @@
# The MIT License (MIT)
Copyright (c) 2018 :author_name <:author_email>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.

43
PULL_REQUEST_TEMPLATE.md Normal file
View File

@ -0,0 +1,43 @@
<!--- Provide a general summary of your changes in the Title above -->
## Description
Describe your changes in detail.
## Motivation and context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here (if you write `fixes #num`
or `closes #num`, the issue will be automatically closed when the pull is accepted.)
## How has this been tested?
Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc.
## Screenshots (if appropriate)
## Types of changes
What types of changes does your code introduce? Put an `x` in all the boxes that apply:
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
## Checklist:
Go over all the following points, and put an `x` in all the boxes that apply.
Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our [continuous integration](http://www.phptherightway.com/#continuous-integration) server to make sure your [tests and code style pass](https://help.github.com/articles/about-required-status-checks/).
- [ ] I have read the **[CONTRIBUTING](CONTRIBUTING.md)** document.
- [ ] My pull request addresses exactly one patch/feature.
- [ ] I have created a branch for this patch/feature.
- [ ] Each individual commit in the pull request is meaningful.
- [ ] I have added tests to cover my changes.
- [ ] If my change requires a change to the documentation, I have updated it accordingly.
If you're unsure about any of these, don't hesitate to ask. We're here to help!

83
README.md Normal file
View File

@ -0,0 +1,83 @@
# :package_name
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-downloads]
**Note:** Replace ```:author_name``` ```:author_username``` ```:author_website``` ```:author_email``` ```:vendor``` ```:package_name``` ```:package_description``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can run `$ php prefill.php` in the command line to make all replacements at once. Delete the file prefill.php as well.
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what
PSRs you support to avoid any confusion with users and contributors.
## Structure
If any of the following are applicable to your project, then the directory structure should follow industry best practices by being named the following.
```
bin/
config/
src/
tests/
vendor/
```
## Install
Via Composer
``` bash
$ composer require :vendor/:package_name
```
## Usage
``` php
$skeleton = new League\Skeleton();
echo $skeleton->echoPhrase('Hello, League!');
```
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.
## Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
## Credits
- [:author_name][link-author]
- [All Contributors][link-contributors]
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/:vendor/:package_name.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/:vendor/:package_name/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/:vendor/:package_name.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/:vendor/:package_name.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/:vendor/:package_name.svg?style=flat-square
[link-packagist]: https://packagist.org/packages/:vendor/:package_name
[link-travis]: https://travis-ci.org/:vendor/:package_name
[link-scrutinizer]: https://scrutinizer-ci.com/g/:vendor/:package_name/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/:vendor/:package_name
[link-downloads]: https://packagist.org/packages/:vendor/:package_name
[link-author]: https://github.com/:author_username
[link-contributors]: ../../contributors

49
composer.json Normal file
View File

@ -0,0 +1,49 @@
{
"name": ":vendor/:package_name",
"type": "library",
"description": ":package_description",
"keywords": [
":vendor",
":package_name"
],
"homepage": "https://github.com/:vendor/:package_name",
"license": "MIT",
"authors": [
{
"name": ":author_name",
"email": ":author_email",
"homepage": ":author_website",
"role": "Developer"
}
],
"require": {
"php" : "~5.6|~7.0"
},
"require-dev": {
"phpunit/phpunit" : ">=5.4.3",
"squizlabs/php_codesniffer": "^3.0"
},
"autoload": {
"psr-4": {
":vendor\\:package_name\\": "src"
}
},
"autoload-dev": {
"psr-4": {
":vendor\\:package_name\\": "tests"
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs src tests",
"fix-style": "phpcbf src tests"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
}
}

14
phpcs.xml.dist Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<ruleset name=":package_name">
<description>The coding standard of :package_name package</description>
<arg value="p" />
<config name="ignore_warnings_on_exit" value="1" />
<config name="ignore_errors_on_exit" value="1" />
<arg name="colors" />
<arg value="s" />
<!-- Use the PSR2 Standard-->
<rule ref="PSR2" />
</ruleset>

28
phpunit.xml.dist Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name=":vendor Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>

129
prefill.php Normal file
View File

@ -0,0 +1,129 @@
<?php
define('COL_DESCRIPTION', 0);
define('COL_HELP', 1);
define('COL_DEFAULT', 2);
$fields = [
'author_name' => ['Your name', '', ''],
'author_github_username' => ['Your Github username', '<username> in https://github.com/username', ''],
'author_email' => ['Your email address', '', ''],
'author_twitter' => ['Your twitter username', '', '@{author_github_username}'],
'author_website' => ['Your website', '', 'https://github.com/{author_github_username}'],
'package_vendor' => ['Package vendor', '<vendor> in https://github.com/vendor/package', '{author_github_username}'],
'package_name' => ['Package name', '<package> in https://github.com/vendor/package', ''],
'package_description' => ['Package very short description', '', ''],
'psr4_namespace' => ['PSR-4 namespace', 'usually, Vendor\\Package', '{package_vendor}\\{package_name}'],
];
$values = [];
$replacements = [
':vendor\\\\:package_name\\\\' => function () use (&$values) {
return str_replace('\\', '\\\\', $values['psr4_namespace']) . '\\\\';
},
':author_name' => function () use (&$values) {
return $values['author_name'];
},
':author_username' => function () use (&$values) {
return $values['author_github_username'];
},
':author_website' => function () use (&$values) {
return $values['author_website'] ?: ('https://github.com/' . $values['author_github_username']);
},
':author_email' => function () use (&$values) {
return $values['author_email'] ?: ($values['author_github_username'] . '@example.com');
},
':vendor' => function () use (&$values) {
return $values['package_vendor'];
},
':package_name' => function () use (&$values) {
return $values['package_name'];
},
':package_description' => function () use (&$values) {
return $values['package_description'];
},
'League\\Skeleton' => function () use (&$values) {
return $values['psr4_namespace'];
},
];
function read_from_console($prompt)
{
if (function_exists('readline')) {
$line = trim(readline($prompt));
if (!empty($line)) {
readline_add_history($line);
}
} else {
echo $prompt;
$line = trim(fgets(STDIN));
}
return $line;
}
function interpolate($text, $values)
{
if (!preg_match_all('/\{(\w+)\}/', $text, $m)) {
return $text;
}
foreach ($m[0] as $k => $str) {
$f = $m[1][$k];
$text = str_replace($str, $values[$f], $text);
}
return $text;
}
$modify = 'n';
do {
if ($modify == 'q') {
exit;
}
$values = [];
echo "----------------------------------------------------------------------\n";
echo "Please, provide the following information:\n";
echo "----------------------------------------------------------------------\n";
foreach ($fields as $f => $field) {
$default = isset($field[COL_DEFAULT]) ? interpolate($field[COL_DEFAULT], $values): '';
$prompt = sprintf(
'%s%s%s: ',
$field[COL_DESCRIPTION],
$field[COL_HELP] ? ' (' . $field[COL_HELP] . ')': '',
$field[COL_DEFAULT] !== '' ? ' [' . $default . ']': ''
);
$values[$f] = read_from_console($prompt);
if (empty($values[$f])) {
$values[$f] = $default;
}
}
echo "\n";
echo "----------------------------------------------------------------------\n";
echo "Please, check that everything is correct:\n";
echo "----------------------------------------------------------------------\n";
echo $field[COL_DESCRIPTION] . ": $values[$f]\n";
}
echo "\n";
} while (($modify = strtolower(read_from_console('Modify files with these values? [y/N/q] '))) != 'y');
echo "\n";
$files = array_merge(
glob(__DIR__ . '/*.md'),
glob(__DIR__ . '/*.xml.dist'),
glob(__DIR__ . '/composer.json'),
glob(__DIR__ . '/src/*.php'),
glob(__DIR__ . '/tests/*.php')
);
foreach ($files as $f) {
$contents = file_get_contents($f);
foreach ($replacements as $str => $func) {
$contents = str_replace($str, $func(), $contents);
}
file_put_contents($f, $contents);
}
echo "Done.\n";
echo "Now you can remove the file '" . basename(__FILE__) . "'.\n";

26
src/SkeletonClass.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace League\Skeleton;
class SkeletonClass
{
/**
* Create a new Skeleton Instance
*/
public function __construct()
{
// constructor body
}
/**
* Friendly welcome
*
* @param string $phrase Phrase to return
*
* @return string Returns the phrase passed in
*/
public function echoPhrase($phrase)
{
return $phrase;
}
}

14
tests/ExampleTest.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace League\Skeleton;
class ExampleTest extends \PHPUnit\Framework\TestCase
{
/**
* Test that true does in fact equal true
*/
public function testTrueIsTrue()
{
$this->assertTrue(true);
}
}