|
| 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 |
0 commit comments