Skip to content

Commit 51d21ef

Browse files
author
Dani Santamaría
committed
[php][step_shotgun_surgery-01_base] Add base
1 parent 35aacd5 commit 51d21ef

24 files changed

+2841
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.php]
13+
indent_size = 4
14+
indent_style = space
15+
16+
[*.md]
17+
trim_trailing_whitespace = false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build:
2+
environment:
3+
php:
4+
version: '7.2'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
:major: 1
3+
:minor: 2
4+
:patch: 1
5+
:special: ''
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: php
2+
3+
sudo: false
4+
5+
php:
6+
- '7.2'
7+
8+
cache:
9+
directories:
10+
- $HOME/.composer/cache
11+
12+
before_install:
13+
- stty cols 120
14+
15+
before_script:
16+
- travis_retry composer self-update
17+
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
18+
19+
script:
20+
- composer lint
21+
- composer style
22+
- composer phpunit
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2018 CodelyTV. https://codely.tv
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# PHP Bootstrap (base / project skeleton)
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Software License][ico-license]][link-license]
5+
[![Build Status][ico-travis]][link-travis]
6+
[![Quality Score][ico-code-quality]][link-code-quality]
7+
[![Total Downloads][ico-downloads]][link-downloads]
8+
9+
## Introduction
10+
11+
This is a repository intended to serve as a starting point if you want to bootstrap a project in PHP. This repository has been explained in the [CodelyTV video "Introducción a PHP: Cómo configurar tu entorno de desarrollo 🐘" (Spanish)](https://www.youtube.com/watch?v=v2IjMrpZog4).
12+
13+
It could be useful if you want to start from scratch a kata or a little exercise or project. The idea is that you don't have to worry about the boilerplate, just run `composer create-project codelytv/php-bootstrap your-project-name` and there you go:
14+
* Latest versions of PHP and PHPUnit
15+
* Best practices applied:
16+
* [`README.md`][link-readme] (badges included)
17+
* [`LICENSE`][link-license]
18+
* [`composer.json`][link-composer-json]
19+
* [`phpunit.xml`][link-phpunit]
20+
* [`.gitignore`][link-gitignore]
21+
* [`.editorconfig`][link-editorconfig]
22+
* [`.travis.yml`][link-travis-yml]
23+
* [`.scrutinizer.yml`][link-scrutinizer]
24+
* Some useful resources to start coding
25+
26+
## How To Start
27+
28+
You have 2 different alternatives: Using our [Packagist project](https://packagist.org/packages/codelytv/php-bootstrap) with Composer, or manually cloning [this repo](https://github.com/CodelyTV/php-bootstrap/):
29+
30+
### Using Composer
31+
32+
Start completely from scratch without having to delete this bootstrap project Git history:
33+
34+
1. If you don't have it already, [install Composer](https://getcomposer.org/download/).
35+
2. Create your project based on the [Packagist project](https://packagist.org/packages/codelytv/php-bootstrap). This will also download the project dependencies: `composer create-project codelytv/php-bootstrap your-project-name`.
36+
3. Move to the project directory: `cd your-project-name`
37+
4. Run all the checks: `composer test`. This will do some checks that you can perform with isolated commands:
38+
1. [PHP Parallel Lint](https://github.com/JakubOnderka/PHP-Parallel-Lint): `composer lint`.
39+
2. [PHP Style Check](https://github.com/squizlabs/PHP_CodeSniffer): `composer style`. If you want to fix style issues automatically: `composer fix-style`.
40+
3. [PHP Unit](https://phpunit.de/): `composer phpunit`.
41+
5. Create your own repository:
42+
1. Initialize your own Git repository: `git init`
43+
2. Add the bootstrap files: `git add .`
44+
3. Commit: `git commit -m "Initial commit with project boilerplate based on https://github.com/CodelyTV/php-bootstrap"`
45+
4. Add your remote repository: `git remote add origin git@github.com:your-username/your-project-name`
46+
5. Upload your local commits to the new remote repo: `git push -u origin master`
47+
6. Start coding!
48+
49+
### Cloning the repository
50+
51+
Just in case you prefer to avoid dealing with `composer create-project`, you can also clone this repository. We recommend to follow the next step by step process in order to avoid adding the bootstrap project commits to your project Git history:
52+
53+
1. Clone this repository: `git clone https://github.com/CodelyTV/php-bootstrap your-project-name`
54+
2. Move to the project directory: `cd your-project-name`
55+
3. If you don't have it already, [install Composer](https://getcomposer.org/download/).
56+
4. Install the project dependencies: `composer install`
57+
5. Run all the checks: `composer test`. This will do some checks that you can perform with isolated commands:
58+
1. [PHP Parallel Lint](https://github.com/JakubOnderka/PHP-Parallel-Lint): `composer lint`.
59+
2. [PHP Style Check](https://github.com/squizlabs/PHP_CodeSniffer): `composer style`. If you want to fix style issues automatically: `composer fix-style`.
60+
3. [PHP Unit](https://phpunit.de/): `composer phpunit`.
61+
6. Create your own repository cleaning the bootstrap project history:
62+
1. Remove previous Git history in order to do not add the bootstrap repo noise in your project: `rm -rf .git`
63+
2. Initialize your own Git repository: `git init`
64+
3. Add the bootstrap files: `git add .`
65+
4. Commit: `git commit -m "Initial commit with project boilerplate based on https://github.com/CodelyTV/php-bootstrap"`
66+
5. Add your remote repository: `git remote add origin git@github.com:your-username/your-project-name`
67+
6. Upload your local commits to the new remote repo: `git push -u origin master`
68+
7. Start coding!
69+
70+
## Helpful resources
71+
72+
### PHP 7
73+
74+
* [PHP 7 new features](http://php.net/manual/en/migration70.new-features.php)
75+
* [Scalar type declarations example](https://github.com/tpunt/PHP7-Reference#scalar-type-declarations)
76+
* [Return type declarations example](https://github.com/tpunt/PHP7-Reference#return-type-declarations)
77+
78+
### PHPUnit
79+
80+
* [Introduction to writing tests for PHPUnit](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
81+
* [Testing exceptions with PHPUnit](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.exceptions)
82+
* [PHPUnit assertions](https://phpunit.de/manual/current/en/appendixes.assertions.html)
83+
84+
### Refactoring
85+
86+
* [Refactoring.guru Code Smells catalog](https://refactoring.guru/smells/smells)
87+
* [Refactoring.guru Refactorings catalog](https://refactoring.guru/catalog)
88+
* [SourceMaking Refactorings catalog](https://sourcemaking.com/refactoring)
89+
* [Martin Fowler Refactorings catalog](http://refactoring.com/catalog/)
90+
* [CodelyTV Refactoring videos (Spanish)](http://codely.tv/tag/refactoring/)
91+
92+
## Other programming languages
93+
94+
* [PHP](https://github.com/CodelyTV/php-bootstrap)
95+
* [Scala](https://github.com/CodelyTV/scala_bootstrap)
96+
97+
## About
98+
99+
This hopefully helpful utility has been developed by [CodelyTV][link-author] and [contributors][link-contributors].
100+
101+
We'll try to maintain this project as simple as possible, but Pull Requests are welcomed!
102+
103+
## License
104+
105+
The MIT License (MIT). Please see [License File][link-license] for more information.
106+
107+
[ico-version]: https://img.shields.io/packagist/v/codelytv/php-bootstrap.svg?style=flat-square
108+
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
109+
[ico-travis]: https://img.shields.io/travis/CodelyTV/php-bootstrap/master.svg?style=flat-square
110+
[ico-code-quality]: https://img.shields.io/scrutinizer/g/CodelyTV/php-bootstrap.svg?style=flat-square
111+
[ico-downloads]: https://img.shields.io/packagist/dt/codelytv/php-bootstrap.svg?style=flat-square
112+
113+
[link-packagist]: https://packagist.org/packages/codelytv/php-bootstrap
114+
[link-license]: LICENSE
115+
[link-travis]: https://travis-ci.org/CodelyTV/php-bootstrap
116+
[link-code-quality]: https://scrutinizer-ci.com/g/CodelyTV/php-bootstrap
117+
[link-downloads]: https://packagist.org/packages/codelytv/php-bootstrap
118+
[link-readme]: README.md
119+
[link-composer-json]: composer.json
120+
[link-phpunit]: phpunit.xml
121+
[link-gitignore]: .gitignore
122+
[link-editorconfig]: .editorconfig
123+
[link-travis-yml]: .travis.yml
124+
[link-scrutinizer]: .scrutinizer.yml
125+
[link-author]: https://github.com/CodelyTV
126+
[link-contributors]: ../../contributors
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "codelytv/php-bootstrap",
3+
"description": "Starting point if you want to bootstrap a project in PHP following best practices.",
4+
"type": "project",
5+
"keywords": [
6+
"bootstrap",
7+
"skeleton",
8+
"kata",
9+
"TDD",
10+
"boilerplate"
11+
],
12+
"homepage": "https://codely.tv",
13+
"time": "2018-07-18",
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "Javier Ferrer",
18+
"email": "javier.ferrer@codely.tv",
19+
"homepage": "https://codely.tv",
20+
"role": "Developer"
21+
},
22+
{
23+
"name": "Rafa Gómez",
24+
"email": "rafa.gomez@codely.tv",
25+
"homepage": "https://codely.tv",
26+
"role": "Developer"
27+
}
28+
],
29+
"require": {
30+
"php": "^7.4"
31+
},
32+
"require-dev": {
33+
"jakub-onderka/php-parallel-lint": "^1.0",
34+
"jakub-onderka/php-console-highlighter": "^0.3",
35+
"squizlabs/php_codesniffer": "^3.3",
36+
"phpunit/phpunit": "^7.2",
37+
"symfony/var-dumper": "^4.1"
38+
},
39+
"autoload": {
40+
"psr-4": {
41+
"CodelyTv\\StepShotgunSurgery\\": "src/"
42+
}
43+
},
44+
"autoload-dev": {
45+
"psr-4": {
46+
"CodelyTv\\StepShotgunSurgery\\Tests\\": "tests/"
47+
}
48+
},
49+
"minimum-stability": "stable",
50+
"config": {
51+
"optimize-autoloader": true
52+
},
53+
"prefer-stable": true,
54+
"scripts": {
55+
"lint": "parallel-lint . --exclude vendor",
56+
"style": "phpcs -p --standard=PSR2 src tests",
57+
"fix-style": "phpcbf -p --standard=PSR2 src tests",
58+
"phpunit": "phpunit --configuration phpunit.xml",
59+
"test": [
60+
"parallel-lint . --exclude vendor",
61+
"phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
62+
"phpunit --configuration phpunit.xml"
63+
]
64+
}
65+
}

0 commit comments

Comments
 (0)