Skip to content

Instantly share code, notes, and snippets.

@mdwheele
Last active May 13, 2020 19:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdwheele/0c77c256bee42f022106 to your computer and use it in GitHub Desktop.
Save mdwheele/0c77c256bee42f022106 to your computer and use it in GitHub Desktop.
Bootstrap for PHP Projects
/.idea
/node_modules
/vendor
composer.phar
composer.lock
.DS_Store
Thumbs.db
npm-debug.log
phpunit.xml
language: php
php:
- 5.3
- 5.4
- 5.5
- hhvm
before_script:
- composer self-update
- composer install
- pyrus install pear/PHP_CodeSniffer
script:
- phpcs --standard=psr2 src/
- phpunit --coverage-text

PHP Composer Package Base

Notice: This an alpha-quality software at the moment. Do NOT use in production anything!!

This repository is meant to be a blank composer package template with a few configuration niceties already established. This includes integrated "support" for PHPUnit, Travis CI, Composer, and more. Even this README.md could serve as a template for your own package documentation. Just add/remove sections as needed.

Goals

  • Bootstrap the process of creating a composer package.

This package is compliant with PSR-1, PSR-2 and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Install

Via Composer

{
    "require": {
        "vendor/package": "dev-master"
    }
}

Requirements

The following versions of PHP are supported by this version.

  • PHP 5.3
  • PHP 5.4
  • PHP 5.5

Documentation

It is typical to include documentation about folks use the packages you write… my work here is done.

// Handle some business

Todo

  • Add usage documentation.
  • Substitute all references of vendor/package with your own.
  • Update list of supported PHP versions.
  • Add your own flair!

Testing

$ phpunit

Contributing

Contributions are welcome and will be fully credited.

We accept contributions via Pull Requests on Github.

Pull Requests

  • PSR-2 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.

  • Add tests! - Your patch won't be accepted if it doesn't have tests.

  • Document any change in behaviour - Make sure the README and any other relevant documentation are kept up-to-date.

  • Consider our release cycle - We try to follow semver. Randomly breaking public APIs is not an option.

  • Create topic 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 before submitting.

Running Tests

$ phpunit

Happy coding!

Credits

License

The MIT License (MIT). Please see License File for more information.

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var exec = require('child_process').exec;
gulp.task('css', function() {
gulp.src('app/assets/scss/main.scss')
.pipe(sass())
.pipe(autoprefixer('last 10 version'))
.pipe(gulp.dest('public/css'));
});
gulp.task('tests', function() {
exec('clear; phpunit', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
});
});
gulp.task('watch', function() {
gulp.watch('app/assets/scss/**/*.scss', ['css']);
gulp.watch(['app/**/*.php', 'src/**/*.php', 'tests/**/*Test.php'], ['tests']);
});
gulp.task('default', ['css', 'tests', 'watch']);
The MIT License (MIT)
Copyright (c) 2014 Dustin Wheeler
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.
{
"devDependencies": {
"gulp": "~3.8.6",
"gulp-autoprefixer": "0.0.8",
"gulp-sass": "~0.7.2"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment