├── .github └── workflows │ └── tests.yml ├── bin └── construct ├── composer.json └── src ├── Commands ├── ConstructCommand.php └── InteractiveCommand.php ├── Composer.php ├── Configuration.php ├── Construct.php ├── Constructors ├── Cli.php ├── CodeOfConduct.php ├── Composer.php ├── Constructor.php ├── ConstructorContract.php ├── Docs.php ├── EditorConfig.php ├── EnvironmentFiles.php ├── GitAttributes.php ├── GitHubDocs.php ├── GitHubTemplates.php ├── GitIgnore.php ├── GitMessage.php ├── LgtmFiles.php ├── License.php ├── PhpCs.php ├── ProjectClass.php ├── Src.php ├── Tests.php ├── Travis.php └── Vagrant.php ├── Defaults.php ├── Exceptions └── ProjectDirectoryToBeAlreadyExists.php ├── GitAttributes.php ├── Helpers ├── Filesystem.php ├── Git.php ├── Script.php ├── Str.php └── Travis.php ├── Settings.php └── stubs ├── CHANGELOG.stub ├── CONDUCT.stub ├── CONTRIBUTING.PHPCS.stub ├── CONTRIBUTING.stub ├── MAINTAINERS.stub ├── Project.stub ├── ProjectTest.stub ├── README.CONDUCT.GITHUB.TEMPLATES.stub ├── README.CONDUCT.stub ├── README.GITHUB.TEMPLATES.stub ├── README.stub ├── Vagrantfile.stub ├── appveyor.stub ├── cli-script.stub ├── composer ├── composer.phpunit.stub └── composer.stub ├── editorconfig.stub ├── env.stub ├── gitattributes.stub ├── github ├── ISSUE_TEMPLATE.stub └── PULL_REQUEST_TEMPLATE.stub ├── gitmessage.stub ├── lgtm.stub ├── licenses ├── apache-2.0.stub ├── gpl-2.0.stub ├── gpl-3.0.stub └── mit.stub ├── phpcs.stub ├── phpspec.stub ├── phpunit.stub ├── travis.phpcs.stub └── travis.stub /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | tests: 14 | name: "PHPUnit Tests (PHP ${{ matrix.php }})" 15 | runs-on: ubuntu-latest 16 | strategy: 17 | matrix: 18 | php: 19 | - "8.0" 20 | - "8.1" 21 | - "8.2" 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v3 25 | 26 | - name: Install PHP 27 | uses: shivammathur/setup-php@v2 28 | with: 29 | php-version: "${{ matrix.php }}" 30 | 31 | - name: Validate composer.json and composer.lock 32 | run: composer validate --strict 33 | 34 | - name: Cache Composer packages 35 | id: composer-cache 36 | uses: actions/cache@v3 37 | with: 38 | path: vendor 39 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 40 | restore-keys: | 41 | ${{ runner.os }}-php- 42 | 43 | - name: Install dependencies 44 | run: composer install --prefer-dist --no-progress 45 | 46 | - name: Run test suite 47 | run: composer construct:test 48 | -------------------------------------------------------------------------------- /bin/construct: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 3 | composer install' . PHP_EOL); 22 | exit(1); 23 | } 24 | 25 | use Construct\Commands\ConstructCommand; 26 | use Construct\Commands\InteractiveCommand; 27 | use Construct\Construct; 28 | use League\Container\Container; 29 | use Symfony\Component\Console\Application; 30 | 31 | $container = new Container(); 32 | $container->add('Construct\Helpers\Filesystem')->withArgument('Construct\Defaults'); 33 | $container->add('Construct\Helpers\Git'); 34 | $container->add('Construct\Helpers\Script')->withArgument('Construct\Helpers\Str'); 35 | $container->add('Construct\Helpers\Str'); 36 | $container->add('Construct\Helpers\Travis')->withArgument('Construct\Helpers\Str'); 37 | $container->add('Construct\Configuration')->withArgument('Construct\Helpers\Filesystem'); 38 | $container->add('Construct\Defaults'); 39 | $container->share('Construct\Settings'); 40 | $container->share('Construct\GitAttributes'); 41 | $container->share('Construct\Composer'); 42 | 43 | $construct = new Construct($container); 44 | $app = new Application('Construct', '3.0.0'); 45 | $app->add(new ConstructCommand($construct)); 46 | $app->add(new InteractiveCommand($construct)); 47 | $app->run(); 48 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jonathantorres/construct", 3 | "description": "PHP project/micro-package generator.", 4 | "keywords": ["php", "project", "package", "structure", "cli"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Jonathan Torres", 9 | "email": "jonathantorres41@gmail.com" 10 | } 11 | ], 12 | "require": { 13 | "php": "^8.0", 14 | "league/container": "^2.4", 15 | "symfony/console": "^2.6 || ^3.0", 16 | "symfony/yaml": "^2.6 || ^3.0", 17 | "composer/composer": "^1.10.0" 18 | }, 19 | "require-dev": { 20 | "friendsofphp/php-cs-fixer": "^2.0", 21 | "mockery/mockery": "^1.0", 22 | "phpstan/phpstan": "^0.12.81", 23 | "phpunit/phpunit": "^8.0" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "Construct\\": "src/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Construct\\Tests\\": "tests/" 33 | } 34 | }, 35 | "config": { 36 | "sort-packages": true 37 | }, 38 | "bin": ["bin/construct"], 39 | "scripts": { 40 | "construct:test": "phpunit", 41 | "construct:cs-fix": "php-cs-fixer fix . -vv || true", 42 | "construct:cs-lint": "php-cs-fixer fix --diff --stop-on-violation --verbose --dry-run", 43 | "construct:static-analysis": "vendor/bin/phpstan analyse -l max -c phpstan.neon src tests" 44 | }, 45 | "scripts-descriptions": { 46 | "construct:test": "Runs all tests.", 47 | "construct:cs-fix": "Fixes existing coding standard violations.", 48 | "construct:cs-lint": "Checks for coding standard violations.", 49 | "construct:static-analysis": "Runs a static code analysis." 50 | }, 51 | "minimum-stability": "stable" 52 | } 53 | -------------------------------------------------------------------------------- /src/Commands/ConstructCommand.php: -------------------------------------------------------------------------------- 1 | construct = $construct; 88 | $this->str = $construct->getContainer()->get('Construct\Helpers\Str'); 89 | $this->filesystem = $construct->getContainer()->get('Construct\Helpers\Filesystem'); 90 | $this->defaults = $construct->getContainer()->get('Construct\Defaults'); 91 | $this->settings = $construct->getContainer()->get('Construct\Settings'); 92 | $this->config = $construct->getContainer()->get('Construct\Configuration'); 93 | 94 | parent::__construct(); 95 | } 96 | 97 | /** 98 | * Command configuration. 99 | * 100 | * @return void 101 | */ 102 | protected function configure() 103 | { 104 | $nameDescription = 'The vendor/project name'; 105 | $testFrameworkDescription = 'Testing framework (one of: ' . join(', ', $this->defaults->getTestingFrameworks()) . ')'; 106 | $cliFrameworkDescription = 'CLI framework'; 107 | $licenseDescription = 'License (one of: ' . join(', ', $this->defaults->getLicenses()) . ')'; 108 | $namespaceDescription = 'Namespace for project'; 109 | $gitDescription = 'Initialize an empty Git repo'; 110 | $phpcsDescription = 'Generate a PHP Coding Standards Fixer configuration'; 111 | $keywordsDescription = 'Comma separated list of Composer keywords'; 112 | $vagrantDescription = 'Generate a Vagrantfile'; 113 | $editorConfigDescription = 'Generate an EditorConfig configuration'; 114 | $phpVersionDescription = 'Project minimun required php version (one of: ' . join(', ', $this->defaults->getPhpVersions()) . ')'; 115 | $environmentDescription = 'Generate .env environment files'; 116 | $lgtmDescription = 'Generate LGTM configuration files'; 117 | $githubTemplatesDescription = 'Generate GitHub templates'; 118 | $githubDocsDescription = 'Generate GitHub docs'; 119 | $githubDescription = 'Generate GitHub templates and docs'; 120 | $codeOfConductDescription = 'Generate Code of Conduct file'; 121 | $configurationDescription = 'Generate from configuration file'; 122 | $ignoreDefaultConfigurationDescription = 'Ignore present default configuration file'; 123 | $configurationDefault = $this->filesystem->getDefaultConfigurationFile(); 124 | 125 | $this->setName('generate'); 126 | $this->setDescription('Generates a basic PHP project/micro-package'); 127 | $this->addArgument('name', InputArgument::REQUIRED, $nameDescription); 128 | $this->addOption('test', 't', InputOption::VALUE_OPTIONAL, $testFrameworkDescription, $this->defaults->getTestingFramework()); 129 | $this->addOption('test-framework', null, InputOption::VALUE_OPTIONAL, $testFrameworkDescription, $this->defaults->getTestingFramework()); 130 | $this->addOption('license', 'l', InputOption::VALUE_OPTIONAL, $licenseDescription, $this->defaults->getLicense()); 131 | $this->addOption('namespace', 's', InputOption::VALUE_OPTIONAL, $namespaceDescription, $this->defaults->getProjectNamespace()); 132 | $this->addOption('git', 'g', InputOption::VALUE_NONE, $gitDescription); 133 | $this->addOption('phpcs', 'p', InputOption::VALUE_NONE, $phpcsDescription); 134 | $this->addOption('keywords', 'k', InputOption::VALUE_OPTIONAL, $keywordsDescription); 135 | $this->addOption('vagrant', null, InputOption::VALUE_NONE, $vagrantDescription); 136 | $this->addOption('editor-config', 'e', InputOption::VALUE_NONE, $editorConfigDescription); 137 | $this->addOption('php', null, InputOption::VALUE_OPTIONAL, $phpVersionDescription, $this->defaults->getSystemPhpVersion()); 138 | $this->addOption('env', null, InputOption::VALUE_NONE, $environmentDescription); 139 | $this->addOption('lgtm', null, InputOption::VALUE_NONE, $lgtmDescription); 140 | $this->addOption('github', null, InputOption::VALUE_NONE, $githubDescription); 141 | $this->addOption('github-templates', null, InputOption::VALUE_NONE, $githubTemplatesDescription); 142 | $this->addOption('github-docs', null, InputOption::VALUE_NONE, $githubDocsDescription); 143 | $this->addOption('code-of-conduct', null, InputOption::VALUE_NONE, $codeOfConductDescription); 144 | $this->addOption('config', 'c', InputOption::VALUE_OPTIONAL, $configurationDescription, $configurationDefault); 145 | $this->addOption('ignore-default-config', 'i', InputOption::VALUE_NONE, $ignoreDefaultConfigurationDescription); 146 | $this->addOption('cli-framework', null, InputOption::VALUE_OPTIONAL, $cliFrameworkDescription, $this->defaults->getCliFramework()); 147 | } 148 | 149 | /** 150 | * Execute command. 151 | * 152 | * @param \Symfony\Component\Console\Input\InputInterface $input 153 | * @param \Symfony\Component\Console\Output\OutputInterface $output 154 | * 155 | * @return void 156 | */ 157 | protected function execute(InputInterface $input, OutputInterface $output) 158 | { 159 | $projectName = $input->getArgument('name'); 160 | $testFramework = $input->getOption('test'); 161 | $testingFramework = $input->getOption('test-framework'); 162 | $license = $input->getOption('license'); 163 | $namespace = $input->getOption('namespace'); 164 | $git = $input->getOption('git'); 165 | $phpcs = $input->getOption('phpcs'); 166 | $keywords = $input->getOption('keywords'); 167 | $vagrant = $input->getOption('vagrant'); 168 | $editorConfig = $input->getOption('editor-config'); 169 | $phpVersion = $input->getOption('php'); 170 | $environment = $input->getOption('env'); 171 | $lgtm = $input->getOption('lgtm'); 172 | $githubTemplates = $input->getOption('github-templates'); 173 | $githubDocs = $input->getOption('github-docs'); 174 | $github = $input->getOption('github'); 175 | $codeOfConduct = $input->getOption('code-of-conduct'); 176 | $ignoreDefaultConfiguration = $input->getOption('ignore-default-config'); 177 | $configuration = $input->getOption('config'); 178 | $cliFramework = null; 179 | 180 | // special case for cli-framework 181 | if ($input->hasParameterOption('--cli-framework')) { 182 | $cliFramework = $input->getOption('cli-framework'); 183 | 184 | if ($cliFramework === null) { 185 | $cliFramework = $this->defaults->getCliFramework(); 186 | } 187 | 188 | if (!$this->str->isValid((string) $cliFramework)) { 189 | $warning = 'Warning: "' . $cliFramework . '" is not a valid Composer package name. Using "' . $this->defaults->getCliFramework() . '" instead.'; 190 | $output->writeln($warning); 191 | $cliFramework = $this->defaults->getCliFramework(); 192 | } 193 | } 194 | 195 | // alias for --test-framework 196 | if ($testingFramework !== $this->defaults->getTestingFramework()) { 197 | $testFramework = $testingFramework; 198 | } 199 | 200 | // Used the --github option, 201 | // so GitHub templates and docs will be generated 202 | if ($github) { 203 | $githubTemplates = $githubDocs = true; 204 | } 205 | 206 | // set the initial project settings 207 | $this->settings->setProjectName((string) $projectName); 208 | $this->settings->setTestingFramework((string) $testFramework); 209 | $this->settings->setLicense((string) $license); 210 | $this->settings->setNamespace((string) $namespace); 211 | $this->settings->setGitInit((boolean) $git); 212 | $this->settings->setPhpcsConfiguration((boolean) $phpcs); 213 | $this->settings->setComposerKeywords((string) $keywords); 214 | $this->settings->setVagrantfile((boolean) $vagrant); 215 | $this->settings->setEditorConfig((boolean) $editorConfig); 216 | $this->settings->setPhpVersion((string) $phpVersion); 217 | $this->settings->setEnvironmentFiles((boolean) $environment); 218 | $this->settings->setLgtmConfiguration((boolean) $lgtm); 219 | $this->settings->setGithubTemplates((boolean) $githubTemplates); 220 | $this->settings->setGithubDocs((boolean) $githubDocs); 221 | $this->settings->setCodeOfConduct((boolean) $codeOfConduct); 222 | $this->settings->setCliFramework((string) $cliFramework); 223 | 224 | // using a .construct configuration file 225 | if ($this->config->isApplicable((string) $configuration) 226 | && $ignoreDefaultConfiguration === false) { 227 | $newSettings = $this->config->overwriteSettings( 228 | $this->settings, 229 | (string) $configuration 230 | ); 231 | 232 | $this->settings = $newSettings; 233 | } 234 | 235 | // warning message if the project name is invalid 236 | if (!$this->str->isValid((string) $projectName)) { 237 | $warningMessage = 'Warning: "' . $projectName . '" is not ' 238 | . 'a valid project name, please use "vendor/project"'; 239 | $output->writeln($warningMessage); 240 | 241 | return false; 242 | } 243 | 244 | $this->warnAndOverwriteInvalidSettingsWithDefaults($output); 245 | 246 | // add constructors here using the current settings (whether from input or from the configuration file) 247 | $this->construct->addConstructor(new Src($this->construct->getContainer())); 248 | $this->construct->addConstructor(new Docs($this->construct->getContainer())); 249 | $this->construct->addConstructor(new Tests($this->construct->getContainer())); 250 | $this->construct->addConstructor(new Cli($this->construct->getContainer())); 251 | $this->construct->addConstructor(new PhpCs($this->construct->getContainer())); 252 | $this->construct->addConstructor(new Vagrant($this->construct->getContainer())); 253 | $this->construct->addConstructor(new EditorConfig($this->construct->getContainer())); 254 | $this->construct->addConstructor(new EnvironmentFiles($this->construct->getContainer())); 255 | $this->construct->addConstructor(new LgtmFiles($this->construct->getContainer())); 256 | $this->construct->addConstructor(new GitHubTemplates($this->construct->getContainer())); 257 | $this->construct->addConstructor(new GitHubDocs($this->construct->getContainer())); 258 | $this->construct->addConstructor(new CodeOfConduct($this->construct->getContainer())); 259 | $this->construct->addConstructor(new Travis($this->construct->getContainer())); 260 | $this->construct->addConstructor(new License($this->construct->getContainer())); 261 | $this->construct->addConstructor(new Composer($this->construct->getContainer())); 262 | $this->construct->addConstructor(new ProjectClass($this->construct->getContainer())); 263 | $this->construct->addConstructor(new GitIgnore($this->construct->getContainer())); 264 | $this->construct->addConstructor(new GitMessage($this->construct->getContainer())); 265 | $this->construct->addConstructor(new GitAttributes($this->construct->getContainer())); 266 | 267 | try { 268 | $this->construct->generate(); 269 | } catch (ProjectDirectoryToBeAlreadyExists $e) { 270 | $warningMessage = 'Warning: "' . $projectName . '" would be ' 271 | . 'constructed into existing directory "' . $this->settings->getProjectLower() . '". ' 272 | . 'Aborting further construction.'; 273 | $output->writeln($warningMessage); 274 | 275 | return false; 276 | } 277 | 278 | $this->initializedGitMessage($output); 279 | $this->bootstrappedCodeceptionMessage($output); 280 | $this->initializedBehatMessage($output); 281 | 282 | $output->writeln('Project "' . $projectName . '" constructed.'); 283 | } 284 | 285 | /** 286 | * Shows warnings and sets new settings which overwrites 287 | * invalid settings with default values. 288 | * 289 | * @param \Symfony\Component\Console\Output\OutputInterface $output 290 | * 291 | * @return void 292 | */ 293 | private function warnAndOverwriteInvalidSettingsWithDefaults(OutputInterface $output) 294 | { 295 | $this->projectNameContainsPhpWarning($output); 296 | 297 | $license = $this->supportedLicenseWarning($output); 298 | $testFramework = $this->testFrameworkWarning($output); 299 | $phpVersion = $this->phpVersionWarning($output); 300 | 301 | $this->settings->setLicense($license); 302 | $this->settings->setTestingFramework($testFramework); 303 | $this->settings->setPhpVersion($phpVersion); 304 | } 305 | 306 | /** 307 | * Show warning if the project name contains the string "php" 308 | * 309 | * @param \Symfony\Component\Console\Output\OutputInterface $output 310 | * 311 | * @return void 312 | */ 313 | private function projectNameContainsPhpWarning(OutputInterface $output) 314 | { 315 | $projectName = $this->settings->getProjectName(); 316 | 317 | if ($this->str->contains($projectName, 'php')) { 318 | $containsPhpWarning = 'Warning: If you are about to create a micro-package "' 319 | . $projectName . '" should optimally not contain a "php" notation in the project name.'; 320 | $output->writeln('' . $containsPhpWarning . ''); 321 | } 322 | } 323 | 324 | /** 325 | * Show warning if a license that is not supported is specified. 326 | * 327 | * @param \Symfony\Component\Console\Output\OutputInterface $output 328 | * 329 | * @return string 330 | */ 331 | private function supportedLicenseWarning(OutputInterface $output): string 332 | { 333 | $license = $this->settings->getLicense(); 334 | 335 | if (!in_array($license, $this->defaults->getLicenses())) { 336 | $warning = 'Warning: "' . $license . '" is not a supported license. ' 337 | . 'Using ' . $this->defaults->getLicense() . '.'; 338 | $output->writeln($warning); 339 | $license = $this->defaults->getLicense(); 340 | } 341 | 342 | return $license; 343 | } 344 | 345 | /** 346 | * Show warning if a test framework that is not supported is specified. 347 | * 348 | * @param \Symfony\Component\Console\Output\OutputInterface $output 349 | * 350 | * @return string 351 | */ 352 | private function testFrameworkWarning(OutputInterface $output): string 353 | { 354 | $testFramework = $this->settings->getTestingFramework(); 355 | 356 | if (!in_array($testFramework, $this->defaults->getTestingFrameworks())) { 357 | $warning = 'Warning: "' . $testFramework . '" is not a supported testing framework. ' 358 | . 'Using ' . $this->defaults->getTestingFramework() . '.'; 359 | $output->writeln($warning); 360 | $testFramework = $this->defaults->getTestingFramework(); 361 | } 362 | 363 | return $testFramework; 364 | } 365 | 366 | /** 367 | * Show warning if an invalid php version or 368 | * a version greater than the one on the system is specified. 369 | * 370 | * @param \Symfony\Component\Console\Output\OutputInterface $output 371 | * 372 | * @return string 373 | */ 374 | private function phpVersionWarning(OutputInterface $output): string 375 | { 376 | $phpVersion = $this->settings->getPhpVersion(); 377 | 378 | if (!$this->str->phpVersionIsValid($phpVersion)) { 379 | $output->writeln('Warning: "' . $phpVersion . '" is not a valid php version. Using version ' . $this->defaults->getSystemPhpVersion() . ''); 380 | $phpVersion = $this->defaults->getSystemPhpVersion(); 381 | } 382 | 383 | if (version_compare($phpVersion, $this->defaults->getSystemPhpVersion(), '>')) { 384 | $output->writeln('Warning: "' . $phpVersion . '" is greater than your installed php version. Using version ' . $this->defaults->getSystemPhpVersion() . ''); 385 | $phpVersion = $this->defaults->getSystemPhpVersion(); 386 | } 387 | 388 | return $phpVersion; 389 | } 390 | 391 | /** 392 | * Show message if an empty git repo is initialized. 393 | * 394 | * @param \Symfony\Component\Console\Output\OutputInterface $output 395 | * 396 | * @return void 397 | */ 398 | private function initializedGitMessage(OutputInterface $output) 399 | { 400 | if ($this->settings->withGitInit()) { 401 | $folder = $this->settings->getProjectLower(); 402 | $output->writeln('Initialized git repo in "' . $folder . '".'); 403 | } 404 | } 405 | 406 | /** 407 | * Show message if codeception is bootstrapped successfully. 408 | * 409 | * @param \Symfony\Component\Console\Output\OutputInterface $output 410 | * 411 | * @return void 412 | */ 413 | private function bootstrappedCodeceptionMessage(OutputInterface $output) 414 | { 415 | if ($this->settings->getTestingFramework() === 'codeception') { 416 | $output->writeln('Bootstrapped codeception.'); 417 | } 418 | } 419 | 420 | /** 421 | * Show message if behat is initialized successfully. 422 | * 423 | * @param \Symfony\Component\Console\Output\OutputInterface $output 424 | * 425 | * @return void 426 | */ 427 | private function initializedBehatMessage(OutputInterface $output) 428 | { 429 | if ($this->settings->getTestingFramework() === 'behat') { 430 | $output->writeln('Initialized behat.'); 431 | } 432 | } 433 | } 434 | -------------------------------------------------------------------------------- /src/Commands/InteractiveCommand.php: -------------------------------------------------------------------------------- 1 | construct = $construct; 57 | $this->str = $construct->getContainer()->get('Construct\Helpers\Str'); 58 | $this->defaults = $construct->getContainer()->get('Construct\Defaults'); 59 | $this->settings = $construct->getContainer()->get('Construct\Settings'); 60 | 61 | parent::__construct(); 62 | } 63 | 64 | /** 65 | * Command configuration. 66 | * 67 | * @return void 68 | */ 69 | protected function configure() 70 | { 71 | $this->setName('generate:interactive'); 72 | $this->setDescription('Generate a basic PHP project/micro-package based on a series of questions.'); 73 | } 74 | 75 | /** 76 | * Execute command. 77 | * 78 | * @param \Symfony\Component\Console\Input\InputInterface $input 79 | * @param \Symfony\Component\Console\Output\OutputInterface $output 80 | * 81 | * @return void 82 | */ 83 | protected function execute(InputInterface $input, OutputInterface $output) 84 | { 85 | $helper = $this->getHelper('question'); 86 | $projectNameQuestion = new Question('What\'s the name of your project? (Format: vendor/project) '); 87 | $projectNameQuestion->setValidator(function ($answer) { 88 | if (!$this->str->isValid($answer)) { 89 | throw new RuntimeException('Error: "' . $answer . '" is not a valid project name, please use "vendor/project"'); 90 | } 91 | 92 | return $answer; 93 | }); 94 | 95 | $testingFrameworkQuestion = new ChoiceQuestion( 96 | 'Which testing framework will you use? Default is "' . $this->defaults->getTestingFramework() . '"', 97 | $this->defaults->getTestingFrameworks(), 98 | 0 99 | ); 100 | 101 | $cliProjectQuestion = new ConfirmationQuestion( 102 | 'Do you want to create a CLI project?', 103 | false 104 | ); 105 | 106 | $cliFrameworkQuestion = new Question( 107 | 'Which CLI Framework will you use? Default is "' . $this->defaults->getCliFramework() . '"', 108 | $this->defaults->getCliFramework() 109 | ); 110 | 111 | $cliFrameworkQuestion->setValidator(function ($answer) { 112 | if (!$this->str->isValid($answer)) { 113 | $exceptionMessage = 'Error: "' . $answer . '" is not a ' 114 | . 'valid Composer package name, please use "vendor/project"'; 115 | throw new RuntimeException($exceptionMessage); 116 | } 117 | 118 | return $answer; 119 | }); 120 | 121 | $licenseQuestion = new ChoiceQuestion( 122 | 'Which open source license will your project use? Default is "' . $this->defaults->getLicense() . '"', 123 | $this->defaults->getLicenses(), 124 | 0 125 | ); 126 | 127 | $phpVersionQuestion = new ChoiceQuestion( 128 | 'What\'s the minimum required php version for this project? Default is "' . $this->defaults->getSystemPhpVersion() . '"', 129 | $this->defaults->getPhpVersions(), 130 | 2 131 | ); 132 | 133 | $namespaceQuestion = new Question('What will be the namespace for the project? Default is "Vendor\Project"', $this->defaults->getProjectNamespace()); 134 | $gitQuestion = new ConfirmationQuestion('Do you want to initialize a local git repository?', false); 135 | $phpCsQuestion = new ConfirmationQuestion('Do you want to generate a PHP Coding Standards Fixer configuration?', false); 136 | $composerKeywordsQuestion = new Question('Supply a comma separated list of keywords for you composer.json (Optional) ', ''); 137 | $vagrantFileQuestion = new ConfirmationQuestion('Do you want to generate a Vagrantfile?', false); 138 | $editorConfigQuestion = new ConfirmationQuestion('Do you want to generate a generate an EditorConfig configuration?', false); 139 | $environmentFileQuestion = new ConfirmationQuestion('Do you want to generate an .env file?', false); 140 | $lgtmFileQuestion = new ConfirmationQuestion('Do you want to generate an LGTM configuration file?', false); 141 | $githubTemplatesQuestion = new ConfirmationQuestion('Do you want to generate GitHub templates?', false); 142 | $githubDocsQuestion = new ConfirmationQuestion('Do you want to generate GitHub docs?', false); 143 | $codeOfConductQuestion = new ConfirmationQuestion('Do you want to add a Code of Conduct file?', false); 144 | 145 | $projectName = $helper->ask($input, $output, $projectNameQuestion); 146 | $testingFramework = $helper->ask($input, $output, $testingFrameworkQuestion); 147 | $cliProject = $helper->ask($input, $output, $cliProjectQuestion); 148 | $cliFramework = null; 149 | 150 | if ($cliProject) { 151 | $cliFramework = $helper->ask($input, $output, $cliFrameworkQuestion); 152 | } 153 | 154 | $license = $helper->ask($input, $output, $licenseQuestion); 155 | $phpVersion = $helper->ask($input, $output, $phpVersionQuestion); 156 | $namespace = $helper->ask($input, $output, $namespaceQuestion); 157 | $git = $helper->ask($input, $output, $gitQuestion); 158 | $phpCs = $helper->ask($input, $output, $phpCsQuestion); 159 | $composerKeywords = $helper->ask($input, $output, $composerKeywordsQuestion); 160 | $vagrantFile = $helper->ask($input, $output, $vagrantFileQuestion); 161 | $editorConfig = $helper->ask($input, $output, $editorConfigQuestion); 162 | $environmentFile = $helper->ask($input, $output, $environmentFileQuestion); 163 | $lgtmFile = $helper->ask($input, $output, $lgtmFileQuestion); 164 | $githubTemplates = $helper->ask($input, $output, $githubTemplatesQuestion); 165 | $githubDocs = $helper->ask($input, $output, $githubDocsQuestion); 166 | $codeOfConduct = $helper->ask($input, $output, $codeOfConductQuestion); 167 | 168 | $this->settings->setProjectName($projectName); 169 | $this->settings->setTestingFramework($testingFramework); 170 | $this->settings->setLicense($license); 171 | $this->settings->setNamespace($namespace); 172 | $this->settings->setGitInit($git); 173 | $this->settings->setPhpcsConfiguration($phpCs); 174 | $this->settings->setComposerKeywords($composerKeywords); 175 | $this->settings->setVagrantfile($vagrantFile); 176 | $this->settings->setEditorConfig($editorConfig); 177 | $this->settings->setPhpVersion($phpVersion); 178 | $this->settings->setEnvironmentFiles($environmentFile); 179 | $this->settings->setLgtmConfiguration($lgtmFile); 180 | $this->settings->setGithubTemplates($githubTemplates); 181 | $this->settings->setGithubDocs($githubDocs); 182 | $this->settings->setCodeOfConduct($codeOfConduct); 183 | $this->settings->setCliFramework($cliFramework); 184 | 185 | $output->writeln('Creating your project...'); 186 | 187 | try { 188 | $this->construct->generate(); 189 | } catch (ProjectDirectoryToBeAlreadyExists $e) { 190 | $warningMessage = 'Warning: "' . $projectName . '" would be ' 191 | . 'constructed into existing directory "' . $this->settings->getProjectLower() . '". ' 192 | . 'Aborting further construction.'; 193 | $output->writeln($warningMessage); 194 | 195 | return false; 196 | } 197 | 198 | $output->writeln('Project "' . $projectName . '" constructed.'); 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /src/Composer.php: -------------------------------------------------------------------------------- 1 | requirements; 31 | } 32 | 33 | /** 34 | * Add a composer requirement 35 | * 36 | * @param string $requirement 37 | * 38 | * @return void 39 | */ 40 | public function addRequirement(string $requirement) 41 | { 42 | $this->requirements[] = $requirement; 43 | } 44 | 45 | /** 46 | * Get the composer development requirements/packages 47 | * 48 | * @return array 49 | */ 50 | public function getDevelopmentRequirements(): array 51 | { 52 | return $this->developmentRequirements; 53 | } 54 | 55 | /** 56 | * Add a composer development requirement 57 | * 58 | * @param string $requirement 59 | * 60 | * @return void 61 | */ 62 | public function addDevelopmentRequirement(string $requirement) 63 | { 64 | $this->developmentRequirements[] = $requirement; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Configuration.php: -------------------------------------------------------------------------------- 1 | filesystem = $filesystem; 28 | } 29 | 30 | /** 31 | * Overwrite the passed in settings with the settings set on the configuration file. 32 | * 33 | * @param \Construct\Settings $settings 34 | * @param string $configurationFile 35 | * 36 | * @return \Construct\Settings 37 | */ 38 | public function overwriteSettings(Settings $settings, string $configurationFile): Settings 39 | { 40 | if (!$this->filesystem->isFile($configurationFile)) { 41 | $exceptionMessage = "Configuration file '$configurationFile' is not existent."; 42 | throw new RuntimeException($exceptionMessage); 43 | } 44 | 45 | if (!$this->filesystem->isReadable($configurationFile)) { 46 | $exceptionMessage = "Configuration file '$configurationFile' is not readable."; 47 | throw new RuntimeException($exceptionMessage); 48 | } 49 | 50 | $configuration = Yaml::parse($this->filesystem->get($configurationFile)); 51 | 52 | // main config settings 53 | if (isset($configuration['construct-with'])) { 54 | $configuration['construct-with'] = array_flip($configuration['construct-with']); 55 | } 56 | 57 | // construct with GitHub files 58 | if (isset($configuration['construct-with']['github'])) { 59 | $configuration['construct-with']['github-templates'] = true; 60 | $configuration['construct-with']['github-docs'] = true; 61 | } 62 | 63 | // set the testing framework 64 | if (isset($configuration['test-framework'])) { 65 | $settings->setTestingFramework($configuration['test-framework']); 66 | } 67 | 68 | // set the open source license 69 | if (isset($configuration['license'])) { 70 | $settings->setLicense($configuration['license']); 71 | } 72 | 73 | // set the namespace 74 | if (isset($configuration['namespace'])) { 75 | $settings->setNamespace($configuration['namespace']); 76 | } 77 | 78 | // initialize an empty git repo? 79 | if (isset($configuration['construct-with']['git'])) { 80 | $settings->setGitInit(true); 81 | } 82 | 83 | // construct with a .phpcs configuration 84 | if (isset($configuration['construct-with']['phpcs'])) { 85 | $settings->setPhpcsConfiguration(true); 86 | } 87 | 88 | // construct with a Vagrantfile 89 | if (isset($configuration['construct-with']['vagrant'])) { 90 | $settings->setVagrantfile(true); 91 | } 92 | 93 | // construct with an .editorconfig file 94 | if (isset($configuration['construct-with']['editor-config'])) { 95 | $settings->setEditorConfig(true); 96 | } 97 | 98 | // set the php version 99 | if (isset($configuration['php'])) { 100 | $settings->setPhpVersion((string) $configuration['php']); 101 | } 102 | 103 | // construct with an environment file 104 | if (isset($configuration['construct-with']['env'])) { 105 | $settings->setEnvironmentFiles(true); 106 | } 107 | 108 | // construct with an lgtm configuration 109 | if (isset($configuration['construct-with']['lgtm'])) { 110 | $settings->setLgtmConfiguration(true); 111 | } 112 | 113 | // construct with GitHub template files 114 | if (isset($configuration['construct-with']['github-templates'])) { 115 | $settings->setGithubTemplates(true); 116 | } 117 | 118 | // construct with a code of conduct file 119 | if (isset($configuration['construct-with']['code-of-conduct'])) { 120 | $settings->setCodeOfConduct(true); 121 | } 122 | 123 | // construct with a GitHub docs file 124 | if (isset($configuration['construct-with']['github-docs'])) { 125 | $settings->setGithubDocs(true); 126 | } 127 | 128 | return $settings; 129 | } 130 | 131 | /** 132 | * Determine if a configuration is applicable. 133 | * 134 | * @param string $configuration The default or a command line provided configuration file. 135 | * 136 | * @return boolean 137 | */ 138 | public function isApplicable($configuration): bool 139 | { 140 | if ($configuration === $this->filesystem->getDefaultConfigurationFile() 141 | && $this->filesystem->hasDefaultConfigurationFile()) { 142 | return true; 143 | } 144 | 145 | if ($configuration !== $this->filesystem->getDefaultConfigurationFile()) { 146 | return true; 147 | } 148 | 149 | return false; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/Construct.php: -------------------------------------------------------------------------------- 1 | container = $container; 50 | $this->settings = $container->get('Construct\Settings'); 51 | $this->filesystem = $container->get('Construct\Helpers\Filesystem'); 52 | } 53 | 54 | /** 55 | * Generates the project using the specified constructors. 56 | * 57 | * @throws ProjectDirectoryToBeAlreadyExists 58 | * @return void 59 | */ 60 | public function generate() 61 | { 62 | $this->saveProjectNames(); 63 | 64 | foreach ($this->constructors as $constructor) { 65 | $constructor->run(); 66 | } 67 | 68 | if ($this->settings->withGitInit()) { 69 | $this->gitInit(); 70 | } 71 | 72 | $this->composerInstall(); 73 | 74 | $this->scripts(); 75 | } 76 | 77 | /** 78 | * Adds a constructor. 79 | * 80 | * @param \Construct\Constructors\ConstructorContract $constructor 81 | * 82 | * @return void 83 | */ 84 | public function addConstructor(ConstructorContract $constructor) 85 | { 86 | $this->constructors[] = $constructor; 87 | } 88 | 89 | /** 90 | * Returns the container instance. 91 | * 92 | * @return \League\Container\Container 93 | */ 94 | public function getContainer(): Container 95 | { 96 | return $this->container; 97 | } 98 | 99 | /** 100 | * Save versions of project names. 101 | * 102 | * @todo Maybe refactor this somewhere else? 103 | * This class shouldn't set project settings 104 | * 105 | * @return void 106 | */ 107 | private function saveProjectNames() 108 | { 109 | $str = $this->container->get('Construct\Helpers\Str'); 110 | $names = $str->split($this->settings->getProjectName()); 111 | 112 | $this->settings->setVendorUpper($str->toStudly($names['vendor'])); 113 | $this->settings->setVendorLower($str->toLower($names['vendor'])); 114 | $this->settings->setProjectUpper($str->toStudly($names['project'])); 115 | $this->settings->setProjectLower($str->toLower($names['project'])); 116 | } 117 | 118 | /** 119 | * Initialize an empty git repo. 120 | * 121 | * @return void 122 | */ 123 | private function gitInit() 124 | { 125 | $git = $this->container->get('Construct\Helpers\Git'); 126 | 127 | if ($this->filesystem->isDirectory($this->settings->getProjectLower())) { 128 | $git->init($this->settings->getProjectLower()); 129 | } 130 | } 131 | 132 | /** 133 | * Do an initial composer install and require the set packages 134 | * in the constructed project. 135 | * 136 | * @return void 137 | */ 138 | private function composerInstall() 139 | { 140 | $script = $this->container->get('Construct\Helpers\Script'); 141 | $composer = $this->container->get('Construct\Composer'); 142 | 143 | if ($this->filesystem->isDirectory($this->settings->getProjectLower())) { 144 | $script->runComposerInstallAndRequirePackages( 145 | $this->settings->getProjectLower(), 146 | $composer->getDevelopmentRequirements(), 147 | $composer->getRequirements() 148 | ); 149 | } 150 | } 151 | 152 | /** 153 | * Run any extra scripts. 154 | * 155 | * @return void 156 | */ 157 | private function scripts() 158 | { 159 | $script = $this->container->get('Construct\Helpers\Script'); 160 | $testingFramework = $this->settings->getTestingFramework(); 161 | 162 | if ($this->filesystem->isDirectory($this->settings->getProjectLower())) { 163 | if ($testingFramework === 'behat') { 164 | $script->initBehat($this->settings->getProjectLower()); 165 | } 166 | 167 | if ($testingFramework === 'codeception') { 168 | $script->bootstrapCodeception($this->settings->getProjectLower()); 169 | } 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/Constructors/Cli.php: -------------------------------------------------------------------------------- 1 | settings->withCliFramework()) { 17 | $this->filesystem->makeDirectory($this->settings->getProjectLower() . '/bin'); 18 | $this->filesystem->copy( 19 | __DIR__ . '/../stubs/cli-script.stub', 20 | $this->settings->getProjectLower() . '/bin/cli-script' 21 | ); 22 | 23 | $appveyorConfiguration = $this->filesystem->get( 24 | __DIR__ . '/../stubs/appveyor.stub' 25 | ); 26 | 27 | $minorPhpVersion = $this->str->toMinorVersion($this->settings->getPhpVersion()); 28 | 29 | $content = str_replace('{php_version}', $minorPhpVersion, $appveyorConfiguration); 30 | $this->filesystem->put($this->settings->getProjectLower() . '/' . '.appveyor.yml', $content); 31 | $this->gitAttributes->addExportIgnore('.appveyor.yml'); 32 | $this->composer->addRequirement($this->settings->getCliFramework()); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Constructors/CodeOfConduct.php: -------------------------------------------------------------------------------- 1 | settings->withCodeOfConduct()) { 17 | $this->filesystem->copy( 18 | __DIR__ . '/../stubs/CONDUCT.stub', 19 | $this->settings->getProjectLower() . '/' . 'CONDUCT.md' 20 | ); 21 | 22 | $this->gitAttributes->addExportIgnore('CONDUCT.md'); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Constructors/Composer.php: -------------------------------------------------------------------------------- 1 | defaults; 17 | $composerFile = 'composer'; 18 | 19 | if ($this->settings->getTestingFramework() === $defaults->getTestingFrameworks()[0]) { 20 | $composerFile .= '.' . $this->settings->getTestingFramework(); 21 | } 22 | $file = $this->filesystem->get(realpath(__DIR__ . '/../stubs/composer/' . $composerFile . '.stub')); 23 | $git = $this->container->get('Construct\Helpers\Git'); 24 | $user = $git->getUser(); 25 | 26 | $stubs = [ 27 | '{project_upper}', 28 | '{project_lower}', 29 | '{vendor_lower}', 30 | '{vendor_upper}', 31 | '{testing}', 32 | '{namespace}', 33 | '{license}', 34 | '{author_name}', 35 | '{author_email}', 36 | '{keywords}', 37 | '{php_version}', 38 | ]; 39 | 40 | $values = [ 41 | $this->settings->getProjectUpper(), 42 | $this->settings->getProjectLower(), 43 | $this->settings->getVendorLower(), 44 | $this->settings->getVendorUpper(), 45 | $this->settings->getTestingFramework(), 46 | $this->createNamespace(true), 47 | $this->settings->getLicense(), 48 | $user['name'], 49 | $user['email'], 50 | $this->str->toQuotedKeywords($this->settings->getComposerKeywords()), 51 | $this->settings->getPhpVersion(), 52 | ]; 53 | 54 | $content = str_replace($stubs, $values, $file); 55 | 56 | $composer = json_decode($content, true); 57 | $composer = array_merge($composer, $this->getScriptsAndTheirDescriptions()); 58 | $content = json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); 59 | $content .= "\n"; 60 | 61 | if ($this->settings->withCliFramework()) { 62 | $composer = json_decode($content, true); 63 | $composer['bin'] = ["bin/cli-script"]; 64 | $content = json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); 65 | $content .= "\n"; 66 | } 67 | 68 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'composer.json', $content); 69 | } 70 | 71 | /** 72 | * Returns the default and settings dependent Composer scripts 73 | * and their descriptions. 74 | * 75 | * @return array 76 | */ 77 | private function getScriptsAndTheirDescriptions() 78 | { 79 | $defaults = $this->defaults; 80 | 81 | $scripts = [ 82 | 'configure-commit-template' => 'git config --add commit.template .gitmessage', 83 | ]; 84 | $descriptions = [ 85 | 'configure-commit-template' => 'Configures a local Git commit message template.', 86 | ]; 87 | 88 | if ($this->settings->withPhpcsConfiguration()) { 89 | $scripts['cs-fix'] = 'php-cs-fixer fix . -vv || true'; 90 | $descriptions['cs-fix'] = 'Fixes existing coding standard violations.'; 91 | 92 | $scripts['cs-lint'] = 'php-cs-fixer fix --diff --stop-on-violation --verbose --dry-run'; 93 | $descriptions['cs-lint'] = 'Checks for coding standard violations.'; 94 | } 95 | 96 | if ($this->settings->getTestingFramework() === $defaults->getTestingFrameworks()[0]) { 97 | $scripts['test'] = $this->settings->getTestingFramework(); 98 | $descriptions['test'] = 'Runs all tests.'; 99 | } 100 | 101 | if ($this->settings->getTestingFramework() === $defaults->getTestingFrameworks()[1]) { 102 | $scripts['test'] = $this->settings->getTestingFramework(); 103 | $descriptions['test'] = 'Runs all features.'; 104 | } 105 | 106 | if ($this->settings->getTestingFramework() === $defaults->getTestingFrameworks()[2]) { 107 | $scripts['test'] = $this->settings->getTestingFramework() . " run --format=pretty"; 108 | $descriptions['test'] = 'Runs all specs.'; 109 | } 110 | 111 | if ($this->settings->getTestingFramework() === $defaults->getTestingFrameworks()[3]) { 112 | $scripts['test'] = "codecept run"; 113 | $descriptions['test'] = 'Runs all tests.'; 114 | } 115 | 116 | $scriptHelper = $this->container->get('Construct\Helpers\Script'); 117 | 118 | if ($scriptHelper->isComposerVersionAvailable()) { 119 | return [ 120 | 'scripts' => $scripts, 121 | 'scripts-descriptions' => $descriptions, 122 | ]; 123 | } 124 | 125 | return [ 126 | 'scripts' => $scripts, 127 | ]; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/Constructors/Constructor.php: -------------------------------------------------------------------------------- 1 | container = $container; 68 | $this->settings = $container->get('Construct\Settings'); 69 | $this->str = $container->get('Construct\Helpers\Str'); 70 | $this->filesystem = $container->get('Construct\Helpers\Filesystem'); 71 | $this->gitAttributes = $container->get('Construct\GitAttributes'); 72 | $this->composer = $container->get('Construct\Composer'); 73 | $this->defaults = $container->get('Construct\Defaults'); 74 | } 75 | 76 | /** 77 | * Construct a correct project namespace name. 78 | * 79 | * @param boolean $useDoubleSlashes Whether or not to create the namespace with double slashes \\ 80 | * 81 | * @return string 82 | */ 83 | protected function createNamespace(bool $useDoubleSlashes = false): string 84 | { 85 | $namespace = $this->settings->getNamespace(); 86 | $projectName = $this->settings->getProjectName(); 87 | 88 | if ($namespace === 'Vendor\Project' || $namespace === $projectName) { 89 | return $this->str->createNamespace($projectName, true, $useDoubleSlashes); 90 | } 91 | 92 | return $this->str->createNamespace($namespace, false, $useDoubleSlashes); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/Constructors/ConstructorContract.php: -------------------------------------------------------------------------------- 1 | readme(); 17 | $this->contributing(); 18 | $this->changelog(); 19 | } 20 | 21 | /** 22 | * Generate README.md file. 23 | * 24 | * @return void 25 | */ 26 | private function readme() 27 | { 28 | if ($this->settings->withCodeOfConduct() === false && $this->settings->withGithubTemplates() === false) { 29 | $readme = $this->filesystem->get(__DIR__ . '/../stubs/README.stub'); 30 | } elseif ($this->settings->withCodeOfConduct() === false && $this->settings-> 31 | withGithubTemplates() === true) { 32 | $readme = $this->filesystem->get(__DIR__ . '/../stubs/README.GITHUB.TEMPLATES.stub'); 33 | } elseif ($this->settings->withCodeOfConduct() === true && $this->settings-> 34 | withGithubTemplates() === false) { 35 | $readme = $this->filesystem->get(__DIR__ . '/../stubs/README.CONDUCT.stub'); 36 | } else { 37 | $readme = $this->filesystem->get(__DIR__ . '/../stubs/README.CONDUCT.GITHUB.TEMPLATES.stub'); 38 | } 39 | 40 | $stubs = [ 41 | '{project_upper}', 42 | '{license}', 43 | '{vendor_lower}', 44 | '{project_lower}' 45 | ]; 46 | 47 | $values = [ 48 | $this->settings->getProjectUpper(), 49 | $this->settings->getLicense(), 50 | $this->settings->getVendorLower(), 51 | $this->settings->getProjectLower() 52 | ]; 53 | 54 | $content = str_replace($stubs, $values, $readme); 55 | 56 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'README.md', $content); 57 | $this->gitAttributes->addExportIgnore('README.md'); 58 | } 59 | 60 | /** 61 | * Generate CONTRIBUTING.md file. 62 | * 63 | * @return void 64 | */ 65 | private function contributing() 66 | { 67 | if ($this->settings->withPhpcsConfiguration()) { 68 | $contributing = $this->filesystem->get(__DIR__ . '/../stubs/CONTRIBUTING.PHPCS.stub'); 69 | } else { 70 | $contributing = $this->filesystem->get(__DIR__ . '/../stubs/CONTRIBUTING.stub'); 71 | } 72 | 73 | $placeholder = ['{project_lower}', '{git_message_path}']; 74 | $replacements = [$this->settings->getProjectLower(), '.gitmessage']; 75 | 76 | if ($this->settings->withGithubTemplates()) { 77 | $replacements = [$this->settings->getProjectLower(), '../.gitmessage']; 78 | } 79 | 80 | $content = str_replace($placeholder, $replacements, $contributing); 81 | 82 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'CONTRIBUTING.md', $content); 83 | $this->gitAttributes->addExportIgnore('CONTRIBUTING.md'); 84 | } 85 | 86 | /** 87 | * Generate CHANGELOG.md file. 88 | * 89 | * @return void 90 | */ 91 | protected function changelog() 92 | { 93 | $changelog = $this->filesystem->get(__DIR__ . '/../stubs/CHANGELOG.stub'); 94 | $content = str_replace( 95 | '{creation_date}', 96 | (new \DateTime())->format('Y-m-d'), 97 | $changelog 98 | ); 99 | 100 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'CHANGELOG.md', $content); 101 | $this->gitAttributes->addExportIgnore('CHANGELOG.md'); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/Constructors/EditorConfig.php: -------------------------------------------------------------------------------- 1 | settings->withEditorConfig()) { 17 | $this->filesystem->copy( 18 | __DIR__ . '/../stubs/editorconfig.stub', 19 | $this->settings->getProjectLower() . '/' . '.editorconfig' 20 | ); 21 | 22 | $this->gitAttributes->addExportIgnore('.editorconfig'); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Constructors/EnvironmentFiles.php: -------------------------------------------------------------------------------- 1 | settings->withEnvironmentFiles()) { 18 | $this->composer->addRequirement('vlucas/phpdotenv'); 19 | 20 | $this->filesystem->copy( 21 | __DIR__ . '/../stubs/env.stub', 22 | $this->settings->getProjectLower() . '/' . '.env' 23 | ); 24 | 25 | $this->filesystem->copy( 26 | __DIR__ . '/../stubs/env.stub', 27 | $this->settings->getProjectLower() . '/' . '.env.example' 28 | ); 29 | 30 | $this->gitAttributes->addExportIgnore('.env'); 31 | $this->gitAttributes->addGitIgnore('.env'); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Constructors/GitAttributes.php: -------------------------------------------------------------------------------- 1 | gitAttributes->addExportIgnore('.gitattributes'); 17 | 18 | $exportIgnores = $this->gitAttributes->getExportIgnores(); 19 | 20 | sort($exportIgnores); 21 | 22 | $content = $this->filesystem->get(__DIR__ . '/../stubs/gitattributes.stub'); 23 | 24 | foreach ($exportIgnores as $ignore) { 25 | $content .= "\n" . $ignore . ' export-ignore'; 26 | } 27 | 28 | $content .= "\n"; 29 | 30 | $this->filesystem->put($this->settings->getProjectLower() . '/' . '.gitattributes', $content); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Constructors/GitHubDocs.php: -------------------------------------------------------------------------------- 1 | settings->withGithubDocs()) { 17 | $this->filesystem->makeDirectory( 18 | $this->settings->getProjectLower() . '/docs', 19 | true 20 | ); 21 | 22 | $this->filesystem->put( 23 | $this->settings->getProjectLower() . '/docs/index.md', 24 | '' 25 | ); 26 | 27 | $this->gitAttributes->addExportIgnore('docs/'); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Constructors/GitHubTemplates.php: -------------------------------------------------------------------------------- 1 | settings->withGithubTemplates()) { 17 | $this->filesystem->makeDirectory( 18 | $this->settings->getProjectLower() . '/.github', 19 | true 20 | ); 21 | 22 | $templates = ['ISSUE_TEMPLATE', 'PULL_REQUEST_TEMPLATE']; 23 | 24 | $stubs = [ 25 | '{license}', 26 | ]; 27 | 28 | $values = [ 29 | $this->settings->getLicense(), 30 | ]; 31 | 32 | foreach ($templates as $template) { 33 | $templateContent = $this->filesystem->get(__DIR__ . '/../stubs/github/' . $template . '.stub'); 34 | $content = str_replace($stubs, $values, $templateContent); 35 | 36 | $this->filesystem->put( 37 | $this->settings->getProjectLower() . '/.github/' . $template . '.md', 38 | $content 39 | ); 40 | } 41 | 42 | $this->filesystem->move( 43 | $this->settings->getProjectLower() . '/CONTRIBUTING.md', 44 | $this->settings->getProjectLower() . '/.github/CONTRIBUTING.md' 45 | ); 46 | 47 | $index = array_search('CONTRIBUTING.md', $this->gitAttributes->getExportIgnores()); 48 | 49 | $this->gitAttributes->removeExportIgnore($index); 50 | $this->gitAttributes->addExportIgnore('.github/'); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Constructors/GitIgnore.php: -------------------------------------------------------------------------------- 1 | gitAttributes->getGitIgnores(); 17 | 18 | sort($gitIgnores, SORT_STRING | SORT_FLAG_CASE); 19 | 20 | $content = ''; 21 | 22 | foreach ($gitIgnores as $ignore) { 23 | $content .= $ignore . "\n"; 24 | } 25 | 26 | $this->filesystem->put($this->settings->getProjectLower() . '/' . '.gitignore', $content); 27 | $this->gitAttributes->addExportIgnore('.gitignore'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Constructors/GitMessage.php: -------------------------------------------------------------------------------- 1 | filesystem->put( 17 | $this->settings->getProjectLower() . '/' . '.gitmessage', 18 | $this->filesystem->get(__DIR__ . '/../stubs/gitmessage.stub') 19 | ); 20 | 21 | $this->gitAttributes->addExportIgnore('.gitmessage'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Constructors/LgtmFiles.php: -------------------------------------------------------------------------------- 1 | settings->withLgtmConfiguration()) { 17 | $this->filesystem->copy( 18 | __DIR__ . '/../stubs/MAINTAINERS.stub', 19 | $this->settings->getProjectLower() . '/' . 'MAINTAINERS' 20 | ); 21 | 22 | $this->filesystem->copy( 23 | __DIR__ . '/../stubs/lgtm.stub', 24 | $this->settings->getProjectLower() . '/' . '.lgtm' 25 | ); 26 | 27 | $this->gitAttributes->addExportIgnore('MAINTAINERS'); 28 | $this->gitAttributes->addExportIgnore('.lgtm'); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Constructors/License.php: -------------------------------------------------------------------------------- 1 | container->get('Construct\Helpers\Git'); 17 | $file = $this->filesystem->get( 18 | __DIR__ . '/../stubs/licenses/' . strtolower($this->settings->getLicense()) . '.stub' 19 | ); 20 | 21 | $user = $git->getUser(); 22 | 23 | $content = str_replace( 24 | ['{year}', '{author_name}'], 25 | [(new \DateTime())->format('Y'), $user['name']], 26 | $file 27 | ); 28 | 29 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'LICENSE.md', $content); 30 | $this->gitAttributes->addExportIgnore('LICENSE.md'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Constructors/PhpCs.php: -------------------------------------------------------------------------------- 1 | settings->withPhpcsConfiguration()) { 18 | $this->composer->addDevelopmentRequirement('friendsofphp/php-cs-fixer'); 19 | 20 | $this->filesystem->copy( 21 | __DIR__ . '/../stubs/phpcs.stub', 22 | $this->settings->getProjectLower() . '/' . '.php_cs' 23 | ); 24 | 25 | $this->gitAttributes->addGitIgnore('.php_cs.cache'); 26 | $this->gitAttributes->addExportIgnore('.php_cs'); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Constructors/ProjectClass.php: -------------------------------------------------------------------------------- 1 | filesystem->get(__DIR__ . '/../stubs/Project.stub'); 17 | 18 | $stubs = [ 19 | '{project_upper}', 20 | '{vendor_upper}', 21 | '{namespace}', 22 | ]; 23 | 24 | $values = [ 25 | $this->settings->getProjectUpper(), 26 | $this->settings->getVendorUpper(), 27 | $this->createNamespace() 28 | ]; 29 | 30 | $content = str_replace($stubs, $values, $file); 31 | 32 | $this->filesystem->put($this->settings->getProjectLower() . '/src/' . $this->settings->getProjectUpper() . '.php', $content); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Constructors/Src.php: -------------------------------------------------------------------------------- 1 | projectDirectoryExists()) { 29 | throw new ProjectDirectoryToBeAlreadyExists(); 30 | } 31 | 32 | $this->filesystem->makeDirectory($this->settings->getProjectLower()); 33 | $this->filesystem->makeDirectory($this->settings->getProjectLower() . '/' . $this->srcPath); 34 | } 35 | 36 | /** 37 | * Checks whether the project directory to be already exist. 38 | * 39 | * @return boolean 40 | */ 41 | private function projectDirectoryExists() 42 | { 43 | return $this->filesystem->isDirectory( 44 | $this->settings->getProjectLower() 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Constructors/Tests.php: -------------------------------------------------------------------------------- 1 | settings->getTestingFramework(); 17 | 18 | $this->{$testingFramework}(); 19 | } 20 | 21 | /** 22 | * Generate phpunit test/file/settings and add package 23 | * to the development requirements. 24 | * 25 | * @return void 26 | */ 27 | private function phpunit() 28 | { 29 | $this->phpunitTest(); 30 | $this->composer->addDevelopmentRequirement('phpunit/phpunit'); 31 | 32 | $file = $this->filesystem->get(__DIR__ . '/../stubs/phpunit.stub'); 33 | $content = str_replace('{project_upper}', $this->settings->getProjectUpper(), $file); 34 | 35 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'phpunit.xml.dist', $content); 36 | $this->gitAttributes->addExportIgnore('phpunit.xml.dist'); 37 | $this->gitAttributes->addGitIgnore('phpunit.xml'); 38 | } 39 | 40 | /** 41 | * Generate phpunit test file. 42 | * 43 | * @return void 44 | */ 45 | private function phpunitTest() 46 | { 47 | $file = $this->filesystem->get(__DIR__ . '/../stubs/ProjectTest.stub'); 48 | 49 | $stubs = [ 50 | '{project_upper}', 51 | '{project_camel_case}', 52 | '{vendor_upper}', 53 | '{namespace}', 54 | ]; 55 | 56 | $values = [ 57 | $this->settings->getProjectUpper(), 58 | $this->str->toCamelCase($this->settings->getProjectLower()), 59 | $this->settings->getVendorUpper(), 60 | $this->createNamespace(), 61 | ]; 62 | 63 | $content = str_replace($stubs, $values, $file); 64 | 65 | $this->filesystem->makeDirectory($this->settings->getProjectLower() . '/tests'); 66 | $this->filesystem->put($this->settings->getProjectLower() . '/tests/' . $this->settings->getProjectUpper() . 'Test.php', $content); 67 | $this->gitAttributes->addExportIgnore('tests/'); 68 | } 69 | 70 | /** 71 | * Generate phpspec config file, create a specs directory and 72 | * add package to development requirements. 73 | * 74 | * @return void 75 | */ 76 | private function phpspec() 77 | { 78 | $this->composer->addDevelopmentRequirement('phpspec/phpspec'); 79 | 80 | $file = $this->filesystem->get(__DIR__ . '/../stubs/phpspec.stub'); 81 | $content = str_replace('{namespace}', $this->createNamespace(), $file); 82 | 83 | $this->filesystem->makeDirectory($this->settings->getProjectLower() . '/specs'); 84 | $this->gitAttributes->addExportIgnore('specs/'); 85 | 86 | $this->filesystem->put($this->settings->getProjectLower() . '/' . 'phpspec.yml.dist', $content); 87 | $this->gitAttributes->addExportIgnore('phpspec.yml.dist'); 88 | $this->gitAttributes->addGitIgnore('phpspec.yml'); 89 | } 90 | 91 | /** 92 | * Add behat to development requirements. 93 | * 94 | * @return void 95 | */ 96 | private function behat() 97 | { 98 | $this->composer->addDevelopmentRequirement('behat/behat'); 99 | } 100 | 101 | /** 102 | * Add codeception to development requirements. 103 | * 104 | * @return void 105 | */ 106 | private function codeception() 107 | { 108 | $this->composer->addDevelopmentRequirement('codeception/codeception'); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Constructors/Travis.php: -------------------------------------------------------------------------------- 1 | str); 19 | 20 | if ($this->settings->withPhpcsConfiguration()) { 21 | $file = $this->filesystem->get(__DIR__ . '/../stubs/travis.phpcs.stub'); 22 | $phpVersionsToRunOnTravis = $travisHelper->phpVersionsToRun( 23 | $travisHelper->phpVersionsToTest($this->settings->getPhpVersion()), 24 | true 25 | ); 26 | } else { 27 | $file = $this->filesystem->get(__DIR__ . '/../stubs/travis.stub'); 28 | $phpVersionsToRunOnTravis = $travisHelper->phpVersionsToRun( 29 | $travisHelper->phpVersionsToTest($this->settings->getPhpVersion()) 30 | ); 31 | } 32 | 33 | $content = str_replace('{phpVersions}', $phpVersionsToRunOnTravis, $file); 34 | 35 | $this->filesystem->put($this->settings->getProjectLower() . '/' . '.travis.yml', $content); 36 | $this->gitAttributes->addExportIgnore('.travis.yml'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Constructors/Vagrant.php: -------------------------------------------------------------------------------- 1 | settings->withVagrantfile()) { 17 | $this->filesystem->copy( 18 | __DIR__ . '/../stubs/Vagrantfile.stub', 19 | $this->settings->getProjectLower() . '/' . 'Vagrantfile' 20 | ); 21 | 22 | $this->gitAttributes->addExportIgnore('Vagrantfile'); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Defaults.php: -------------------------------------------------------------------------------- 1 | systemPhpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION; 87 | } 88 | 89 | /** 90 | * Get the available open source licenses. 91 | * 92 | * @return array 93 | */ 94 | public function getLicenses(): array 95 | { 96 | return $this->licenses; 97 | } 98 | 99 | /** 100 | * Get the supported testing frameworks. 101 | * 102 | * @return array 103 | */ 104 | public function getTestingFrameworks(): array 105 | { 106 | return $this->testingFrameworks; 107 | } 108 | 109 | /** 110 | * Get the available php versions to test on Travis. 111 | * 112 | * @return array 113 | */ 114 | public function getPhpVersions(): array 115 | { 116 | return $this->phpVersions; 117 | } 118 | 119 | /** 120 | * Get the php versions without a semver scheme. 121 | * 122 | * @return array 123 | */ 124 | public function getNonSemverPhpVersions(): array 125 | { 126 | return $this->nonSemverPhpVersions; 127 | } 128 | 129 | /** 130 | * Get the default CLI Framework. 131 | * 132 | * @return string 133 | */ 134 | public function getCliFramework(): string 135 | { 136 | return $this->cliFramework; 137 | } 138 | 139 | /** 140 | * Get the default testing framework. 141 | * 142 | * @return string 143 | */ 144 | public function getTestingFramework(): string 145 | { 146 | return $this->testingFramework; 147 | } 148 | 149 | /** 150 | * Get the default license. 151 | * 152 | * @return string 153 | */ 154 | public function getLicense(): string 155 | { 156 | return $this->license; 157 | } 158 | 159 | /** 160 | * Get the default project namespace. 161 | * 162 | * @return string 163 | */ 164 | public function getProjectNamespace(): string 165 | { 166 | return $this->projectNamespace; 167 | } 168 | 169 | /** 170 | * Get the default name of the configuration file. 171 | * 172 | * @return string 173 | */ 174 | public function getConfigurationFile(): string 175 | { 176 | return $this->configurationFile; 177 | } 178 | 179 | /** 180 | * Get the php version currently installed on the system. 181 | * 182 | * @return string 183 | */ 184 | public function getSystemPhpVersion(): string 185 | { 186 | return $this->systemPhpVersion; 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/Exceptions/ProjectDirectoryToBeAlreadyExists.php: -------------------------------------------------------------------------------- 1 | exportIgnores; 31 | } 32 | 33 | /** 34 | * Add a file to the export ignores 35 | * 36 | * @param string $ignore 37 | * 38 | * @return void 39 | */ 40 | public function addExportIgnore(string $ignore) 41 | { 42 | $this->exportIgnores[] = $ignore; 43 | } 44 | 45 | /** 46 | * Remove a file from the export ignores 47 | * 48 | * @param string $ignore 49 | * 50 | * @return void 51 | */ 52 | public function removeExportIgnore($ignore) 53 | { 54 | unset($this->exportIgnores[$ignore]); 55 | } 56 | 57 | /** 58 | * Get the directories and files to ignore on git repositories. 59 | * 60 | * @return array 61 | */ 62 | public function getGitIgnores(): array 63 | { 64 | return $this->gitIgnores; 65 | } 66 | 67 | /** 68 | * Add a file to the .gitignore 69 | * 70 | * @param string $ignore 71 | * 72 | * @return void 73 | */ 74 | public function addGitIgnore(string $ignore) 75 | { 76 | $this->gitIgnores[] = $ignore; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Helpers/Filesystem.php: -------------------------------------------------------------------------------- 1 | defaults = $defaults; 26 | } 27 | 28 | /** 29 | * Create a directory 30 | * 31 | * @param string $path 32 | * @param boolean $recursive Defaults to false. 33 | * 34 | * @return boolean 35 | */ 36 | public function makeDirectory(string $path, bool $recursive = false): bool 37 | { 38 | return mkdir($path, 0777, $recursive); 39 | } 40 | 41 | /** 42 | * Check if the path is a directory. 43 | * 44 | * @param string $path 45 | * 46 | * @return boolean 47 | */ 48 | public function isDirectory(string $path): bool 49 | { 50 | return is_dir($path); 51 | } 52 | 53 | /** 54 | * Check if the path is a file. 55 | * 56 | * @param string $path 57 | * 58 | * @return boolean 59 | */ 60 | public function isFile(string $path): bool 61 | { 62 | return is_file($path); 63 | } 64 | 65 | /** 66 | * Check if the path is readable. 67 | * 68 | * @param string $path 69 | * 70 | * @return boolean 71 | */ 72 | public function isReadable(string $path): bool 73 | { 74 | return is_readable($path); 75 | } 76 | 77 | /** 78 | * Get the home directory. 79 | * 80 | * @param string $os 81 | * 82 | * @return string 83 | */ 84 | public function getHomeDirectory(string $os = PHP_OS): string 85 | { 86 | if (strtoupper(substr($os, 0, 3)) !== 'WIN') { 87 | return getenv('HOME'); 88 | } 89 | 90 | return getenv('userprofile'); 91 | } 92 | 93 | /** 94 | * Get the default construct configuration file. 95 | * 96 | * @return string 97 | */ 98 | public function getDefaultConfigurationFile(): string 99 | { 100 | return $this->getHomeDirectory() 101 | . DIRECTORY_SEPARATOR 102 | . $this->defaults->getConfigurationFile(); 103 | } 104 | 105 | /** 106 | * Determine if system has a default configuration file. 107 | * 108 | * @return boolean 109 | */ 110 | public function hasDefaultConfigurationFile(): bool 111 | { 112 | return $this->isFile($this->getDefaultConfigurationFile()); 113 | } 114 | 115 | /** 116 | * Copy the given file a new location. 117 | * 118 | * @param string $path 119 | * @param string $target 120 | * 121 | * @return boolean 122 | */ 123 | public function copy(string $path, string $target): bool 124 | { 125 | return copy($path, $target); 126 | } 127 | 128 | /** 129 | * Move the given file to a new location. 130 | * 131 | * @param string $path 132 | * @param string $target 133 | * 134 | * @return void 135 | */ 136 | public function move(string $path, string $target) 137 | { 138 | $this->copy($path, $target); 139 | 140 | unlink($path); 141 | } 142 | 143 | /** 144 | * Get the contents of a file. 145 | * 146 | * @param string $path 147 | * 148 | * @return string 149 | */ 150 | public function get(string $path): string 151 | { 152 | return file_get_contents($path); 153 | } 154 | 155 | /** 156 | * Write the contents of a file. 157 | * 158 | * @param string $path 159 | * @param string $contents 160 | * 161 | * @return int 162 | */ 163 | public function put(string $path, $contents): int 164 | { 165 | return file_put_contents($path, $contents); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/Helpers/Git.php: -------------------------------------------------------------------------------- 1 | 'Some name', 32 | 'email' => 'some@email.com' 33 | ]; 34 | 35 | $command = 'git config --get-regexp "^user.*"'; 36 | 37 | exec($command, $keyValueLines, $returnValue); 38 | 39 | if ($returnValue === 0) { 40 | foreach ($keyValueLines as $keyValueLine) { 41 | list($key, $value) = explode(' ', $keyValueLine, 2); 42 | $key = str_replace('user.', '', $key); 43 | $user[$key] = $value; 44 | } 45 | } 46 | 47 | return $user; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Helpers/Script.php: -------------------------------------------------------------------------------- 1 | str = $str; 24 | } 25 | 26 | /** 27 | * Do an initial composer install in constructed project and require 28 | * the development and non development packages. 29 | * 30 | * @param string $folder The folder to execute the command(s) in. 31 | * @param array $developmentPackages The development packages to require. 32 | * @param array $packages The packages to require. 33 | * 34 | * @return void 35 | */ 36 | public function runComposerInstallAndRequirePackages( 37 | string $folder, 38 | array $developmentPackages, 39 | array $packages = [] 40 | ) { 41 | $command = 'cd ' . $folder . ' && composer install'; 42 | 43 | if (count($developmentPackages) > 0) { 44 | $command .= ' && composer require --dev ' . implode(' ', $developmentPackages); 45 | } 46 | 47 | if (count($packages) > 0) { 48 | $command .= ' && composer require ' . implode(' ', $packages); 49 | } 50 | 51 | exec($command); 52 | } 53 | 54 | /** 55 | * Checks if a given Composer version or greater is 56 | * available on the runtime system. 57 | * 58 | * @param string $version Defaults to version 1.6.0. 59 | * @return boolean 60 | */ 61 | public function isComposerVersionAvailable($version = '1.6.0') 62 | { 63 | $requiredMinorVersion = $this->str->toMinorVersion($version); 64 | $command = 'composer --version'; 65 | 66 | exec($command, $version, $returnValue); 67 | 68 | if ($returnValue === 0) { 69 | $availableMinorVersion = $this->str->toMinorVersion( 70 | explode(' ', $version[0])[1] 71 | ); 72 | 73 | return version_compare( 74 | $requiredMinorVersion, 75 | $availableMinorVersion, 76 | '<=' 77 | ) === true; 78 | } 79 | 80 | return true; 81 | } 82 | 83 | /** 84 | * Generate default behat context. 85 | * 86 | * @param string $folder 87 | * 88 | * @return void 89 | */ 90 | public function initBehat(string $folder) 91 | { 92 | $command = 'cd ' . $folder . ' && vendor/bin/behat --init'; 93 | 94 | exec($command); 95 | } 96 | 97 | /** 98 | * Generate default codeception suites. 99 | * 100 | * @param string $folder 101 | * 102 | * @return void 103 | */ 104 | public function bootstrapCodeception(string $folder) 105 | { 106 | $command = 'cd ' . $folder . ' && vendor/bin/codecept bootstrap'; 107 | 108 | exec($command); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Helpers/Str.php: -------------------------------------------------------------------------------- 1 | regEx, $name) === 0) { 28 | return false; 29 | } 30 | 31 | return true; 32 | } 33 | 34 | /** 35 | * Check if the entered project name contains a given string. 36 | * 37 | * @param string $name 38 | * @param string $needle 39 | * 40 | * @return boolean 41 | */ 42 | public function contains(string $name, string $needle): bool 43 | { 44 | return strstr($name, $needle) !== false; 45 | } 46 | 47 | /** 48 | * Convert string to lower case. 49 | * 50 | * @param string $string 51 | * 52 | * @return string 53 | */ 54 | public function toLower(string $string): string 55 | { 56 | return strtolower($string); 57 | } 58 | 59 | /** 60 | * Convert string to studly case. 61 | * 62 | * @param string $string 63 | * 64 | * @return string 65 | */ 66 | public function toStudly(string $string): string 67 | { 68 | $value = ucwords(str_replace(['-', '_'], ' ', $string)); 69 | 70 | return str_replace(' ', '', $value); 71 | } 72 | 73 | /** 74 | * Convert string to camel case. 75 | * 76 | * @param string $string 77 | * @param boolean $capitalizeFirstCharacter 78 | * 79 | * @return string 80 | */ 81 | public function toCamelCase(string $string, bool $capitalizeFirstCharacter = false): string 82 | { 83 | $string = str_replace( 84 | ' ', 85 | '', 86 | ucwords(str_replace(['-', '_'], ' ', $string)) 87 | ); 88 | 89 | if (!$capitalizeFirstCharacter) { 90 | $string = lcfirst($string); 91 | } 92 | 93 | return $string; 94 | } 95 | 96 | /** 97 | * Split project name in a pretty array. 98 | * 99 | * @param string $string 100 | * 101 | * @return array 102 | */ 103 | public function split(string $string): array 104 | { 105 | $project = explode('/', $string); 106 | 107 | return [ 108 | 'vendor' => $project[0], 109 | 'project' => $project[1], 110 | ]; 111 | } 112 | 113 | /** 114 | * Construct a correct project namespace name. 115 | * 116 | * @param string $namespace The entered namespace. 117 | * @param boolean $usesProjectName Whether or not it's using the project name. 118 | * @param boolean $useDoubleSlashes Whether or not use double slashes \\. 119 | * 120 | * @return string 121 | */ 122 | public function createNamespace(string $namespace, bool $usesProjectName = false, bool $useDoubleSlashes = false): string 123 | { 124 | $delimiter = $usesProjectName ? '/' : '\\'; 125 | $slash = $useDoubleSlashes ? '\\\\' : '\\'; 126 | 127 | // strip dots and dashes from project name 128 | if ($usesProjectName) { 129 | $namespace = str_replace(['-', '.'], '_', $namespace); 130 | $namespace = $this->toStudly($namespace); 131 | } 132 | 133 | return implode($slash, array_map(function ($v) { 134 | return $this->toStudly($v); 135 | }, explode($delimiter, $namespace))); 136 | } 137 | 138 | /** 139 | * Check if the operating system is windowsish. 140 | * 141 | * @param string $os 142 | * 143 | * @return boolean 144 | */ 145 | public function isWindows(string $os = PHP_OS): bool 146 | { 147 | if (strtoupper(substr($os, 0, 3)) !== 'WIN') { 148 | return false; 149 | } 150 | 151 | return true; 152 | } 153 | 154 | /** 155 | * Convert keywords to quoted keywords. 156 | * Ex: "test,php,vagrant,provision" -> '"test","php","vagrant","provision"' 157 | * 158 | * @param string $keywords 159 | * 160 | * @return string 161 | */ 162 | public function toQuotedKeywords($keywords): string 163 | { 164 | if ($keywords == null || trim($keywords) == '') { 165 | return ''; 166 | } 167 | 168 | $keywordsQuoted = array_map(function ($keyword) { 169 | return '"' . trim($keyword) . '"'; 170 | }, explode(',', $keywords)); 171 | 172 | return implode(', ', $keywordsQuoted); 173 | } 174 | 175 | /** 176 | * Returns the minor version of the given version. 177 | * 178 | * @param string $version 179 | * 180 | * @return string 181 | */ 182 | public function toMinorVersion(string $version): string 183 | { 184 | list($major, $minor) = explode('.', $version); 185 | 186 | return $major . '.' . $minor; 187 | } 188 | 189 | /** 190 | * Validate php version string 191 | * 192 | * @param string $version 193 | * 194 | * @return boolean 195 | */ 196 | public function phpVersionIsValid(string $version): bool 197 | { 198 | return preg_match('/\d\.\d(\.\d)?/', $version) === 1; 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /src/Helpers/Travis.php: -------------------------------------------------------------------------------- 1 | str = $str; 24 | } 25 | 26 | /** 27 | * Get project php versions that will be run on travis ci. 28 | * 29 | * @param string $projectPhpVersion 30 | * 31 | * @return array 32 | */ 33 | public function phpVersionsToTest($projectPhpVersion): array 34 | { 35 | $supportedPhpVersions = (new Defaults)->getPhpVersions(); 36 | $versionsToTest = (new Defaults)->getNonSemverPhpVersions(); 37 | 38 | $phpVersionsToTest = array_filter($supportedPhpVersions, function ($supportedPhpVersion) use ($projectPhpVersion) { 39 | return version_compare( 40 | $this->str->toMinorVersion($projectPhpVersion), 41 | $this->str->toMinorVersion($supportedPhpVersion), 42 | '<=' 43 | ) === true; 44 | }); 45 | 46 | return array_merge($versionsToTest, $phpVersionsToTest); 47 | } 48 | 49 | /** 50 | * Generate string that specifies the php versions that will be run on travis. 51 | * 52 | * @param array $phpVersions 53 | * @param boolean $setLintEnvironmentVariable 54 | * 55 | * @return string 56 | */ 57 | public function phpVersionsToRun($phpVersions, $setLintEnvironmentVariable = false): string 58 | { 59 | $runOn = ''; 60 | $nonSemverVersions = (new Defaults)->getNonSemverPhpVersions(); 61 | $alreadySetLintEnvironmentVariable = false; 62 | 63 | for ($i = 0; $i < count($phpVersions); $i++) { 64 | $phpVersion = $phpVersions[$i]; 65 | 66 | if (!in_array($phpVersions[$i], $nonSemverVersions)) { 67 | $phpVersion = $this->str->toMinorVersion($phpVersions[$i]); 68 | } 69 | 70 | if ($i >= 0) { 71 | $runOn .= ' '; 72 | } 73 | 74 | $runOn .= '- php: ' . $phpVersions[$i]; 75 | 76 | if ($setLintEnvironmentVariable 77 | && count($phpVersions) == $i + 1 78 | && $alreadySetLintEnvironmentVariable == false 79 | ) { 80 | $alreadySetLintEnvironmentVariable = true; 81 | $runOn .= "\n env:" 82 | . "\n - LINT=true"; 83 | } 84 | 85 | if ($i !== (count($phpVersions) - 1)) { 86 | $runOn .= "\n"; 87 | } 88 | } 89 | 90 | return $runOn; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Settings.php: -------------------------------------------------------------------------------- 1 | projectName; 161 | } 162 | 163 | /** 164 | * Set the entered project name. 165 | * 166 | * @param string $name 167 | * 168 | * @return void 169 | */ 170 | public function setProjectName(string $name) 171 | { 172 | $this->projectName = $name; 173 | } 174 | 175 | /** 176 | * Set the studly case version of the vendor name. 177 | * 178 | * @param string $vendorUpper 179 | * 180 | * @return void 181 | */ 182 | public function setVendorUpper(string $vendorUpper) 183 | { 184 | $this->vendorUpper = $vendorUpper; 185 | } 186 | 187 | /** 188 | * Get the studly case version of the vendor name. 189 | * 190 | * @return string 191 | */ 192 | public function getVendorUpper(): string 193 | { 194 | return $this->vendorUpper; 195 | } 196 | 197 | /** 198 | * Set the lower case version of the vendor name. 199 | * 200 | * @param string $vendorLower 201 | * 202 | * @return void 203 | */ 204 | public function setVendorLower(string $vendorLower) 205 | { 206 | $this->vendorLower = $vendorLower; 207 | } 208 | 209 | /** 210 | * Get the lower case version of the vendor name. 211 | * 212 | * @return string 213 | */ 214 | public function getVendorLower(): string 215 | { 216 | return $this->vendorLower; 217 | } 218 | 219 | /** 220 | * Set the studly case version of the project name 221 | * 222 | * @param string $projectUpper 223 | * 224 | * @return void 225 | */ 226 | public function setProjectUpper(string $projectUpper) 227 | { 228 | $this->projectUpper = $projectUpper; 229 | } 230 | 231 | /** 232 | * Get the studly case version of the project name. 233 | * 234 | * @return string 235 | */ 236 | public function getProjectUpper(): string 237 | { 238 | return $this->projectUpper; 239 | } 240 | 241 | /** 242 | * Set the lower case version of the project name. 243 | * 244 | * @param string $projectLower 245 | * 246 | * @return void 247 | */ 248 | public function setProjectLower(string $projectLower) 249 | { 250 | $this->projectLower = $projectLower; 251 | } 252 | 253 | /** 254 | * Get the lower case version of the project name 255 | * 256 | * @return string 257 | */ 258 | public function getProjectLower(): string 259 | { 260 | return $this->projectLower; 261 | } 262 | 263 | /** 264 | * Get the entered testing framework. 265 | * 266 | * @return string 267 | */ 268 | public function getTestingFramework(): string 269 | { 270 | return $this->testingFramework; 271 | } 272 | 273 | /** 274 | * Set the entered testing framework. 275 | * 276 | * @param string $testingFramework 277 | * 278 | * @return void 279 | */ 280 | public function setTestingFramework(string $testingFramework) 281 | { 282 | $this->testingFramework = $testingFramework; 283 | } 284 | 285 | /** 286 | * Get the entered license. 287 | * 288 | * @return string 289 | */ 290 | public function getLicense(): string 291 | { 292 | return $this->license; 293 | } 294 | 295 | /** 296 | * Set the entered license. 297 | * 298 | * @param string $license 299 | * 300 | * @return void 301 | */ 302 | public function setLicense(string $license) 303 | { 304 | $this->license = $license; 305 | } 306 | 307 | /** 308 | * Get the entered namespace. 309 | * 310 | * @return string 311 | */ 312 | public function getNamespace(): string 313 | { 314 | return $this->namespace; 315 | } 316 | 317 | /** 318 | * Set the entered namespace. 319 | * 320 | * @param string $namespace 321 | * 322 | * @return void 323 | */ 324 | public function setNamespace(string $namespace) 325 | { 326 | $this->namespace = $namespace; 327 | } 328 | 329 | /** 330 | * Whether or not to initialize a git repo on the project. 331 | * 332 | * @return boolean 333 | */ 334 | public function withGitInit() 335 | { 336 | return $this->gitInit; 337 | } 338 | 339 | /** 340 | * Set whether or not to initialize a git repo on the project. 341 | * 342 | * @param boolean $gitInit 343 | * 344 | * @return void 345 | */ 346 | public function setGitInit(bool $gitInit) 347 | { 348 | $this->gitInit = $gitInit; 349 | } 350 | 351 | /** 352 | * Whether or not to use phpcs on the project. 353 | * 354 | * @return boolean 355 | */ 356 | public function withPhpcsConfiguration() 357 | { 358 | return $this->phpcsConfiguration; 359 | } 360 | 361 | /** 362 | * Set whether or not to use phpcs on the project. 363 | * 364 | * @param boolean $configuration 365 | * 366 | * @return void 367 | */ 368 | public function setPhpcsConfiguration(bool $configuration) 369 | { 370 | $this->phpcsConfiguration = $configuration; 371 | } 372 | 373 | /** 374 | * Get the entered Composer keywords. 375 | * 376 | * @return string 377 | */ 378 | public function getComposerKeywords() 379 | { 380 | return $this->composerKeywords; 381 | } 382 | 383 | /** 384 | * Set the entered Composer keywords. 385 | * 386 | * @param string $keywords 387 | * 388 | * @return void 389 | */ 390 | public function setComposerKeywords($keywords) 391 | { 392 | $this->composerKeywords = $keywords; 393 | } 394 | 395 | /** 396 | * Whether or not to create a Vagrantfile. 397 | * 398 | * @return boolean 399 | */ 400 | public function withVagrantfile() 401 | { 402 | return $this->vagrantfile; 403 | } 404 | 405 | /** 406 | * Set whether or not to create a Vagrantfile. 407 | * 408 | * @param boolean $vagrantfile 409 | * 410 | * @return void 411 | */ 412 | public function setVagrantfile(bool $vagrantfile) 413 | { 414 | $this->vagrantfile = $vagrantfile; 415 | } 416 | 417 | /** 418 | * Whether or not to create an EditorConfig file. 419 | * 420 | * @return boolean 421 | */ 422 | public function withEditorConfig() 423 | { 424 | return $this->editorConfig; 425 | } 426 | 427 | /** 428 | * Set whether or not to create an EditorConfig file. 429 | * 430 | * @param boolean $config 431 | * 432 | * @return void 433 | */ 434 | public function setEditorConfig(bool $config) 435 | { 436 | $this->editorConfig = $config; 437 | } 438 | 439 | /** 440 | * Get the entered project php version. 441 | * 442 | * @return string 443 | */ 444 | public function getPhpVersion(): string 445 | { 446 | return $this->phpVersion; 447 | } 448 | 449 | /** 450 | * Set the entered project php version. 451 | * 452 | * @param string $version 453 | * 454 | * @return void 455 | */ 456 | public function setPhpVersion(string $version) 457 | { 458 | $this->phpVersion = $version; 459 | } 460 | 461 | /** 462 | * Whether or not to create .env environment files. 463 | * 464 | * @return boolean 465 | */ 466 | public function withEnvironmentFiles() 467 | { 468 | return $this->environmentFiles; 469 | } 470 | 471 | /** 472 | * Set whether or not to create .env environment files. 473 | * 474 | * @param boolean $envFiles 475 | * 476 | * @return void 477 | */ 478 | public function setEnvironmentFiles(bool $envFiles) 479 | { 480 | $this->environmentFiles = $envFiles; 481 | } 482 | 483 | /** 484 | * Whether or not to create LGTM configuration files. 485 | * 486 | * @return boolean 487 | */ 488 | public function withLgtmConfiguration() 489 | { 490 | return $this->lgtmConfiguration; 491 | } 492 | 493 | /** 494 | * Set whether or not to create an LGTM configuration file. 495 | * 496 | * @param boolean $configuration 497 | * 498 | * @return void 499 | */ 500 | public function setLgtmConfiguration(bool $configuration) 501 | { 502 | $this->lgtmConfiguration = $configuration; 503 | } 504 | 505 | /** 506 | * Whether or not to create GitHub template files. 507 | * 508 | * @return boolean 509 | */ 510 | public function withGithubTemplates(): bool 511 | { 512 | return $this->githubTemplates; 513 | } 514 | 515 | /** 516 | * Set whether or not to create GitHub template files. 517 | * 518 | * @param boolean $templates 519 | * 520 | * @return void 521 | */ 522 | public function setGithubTemplates(bool $templates) 523 | { 524 | $this->githubTemplates = $templates; 525 | } 526 | 527 | /** 528 | * Whether or not to create GitHub documentation files. 529 | * 530 | * @return boolean 531 | */ 532 | public function withGithubDocs(): bool 533 | { 534 | return $this->githubDocs; 535 | } 536 | 537 | /** 538 | * Set whether or not to create GitHub documentation files. 539 | * 540 | * @param boolean $docs 541 | * 542 | * @return void 543 | */ 544 | public function setGithubDocs(bool $docs) 545 | { 546 | $this->githubDocs = $docs; 547 | } 548 | 549 | /** 550 | * Whether or not to create a Code of Conduct file. 551 | * 552 | * @return boolean 553 | */ 554 | public function withCodeOfConduct(): bool 555 | { 556 | return $this->codeOfConduct; 557 | } 558 | 559 | /** 560 | * Set whether or not to create a Code of Conduct file. 561 | * 562 | * @param boolean $codeOfConduct 563 | * 564 | * @return void 565 | */ 566 | public function setCodeOfConduct(bool $codeOfConduct) 567 | { 568 | $this->codeOfConduct = $codeOfConduct; 569 | } 570 | 571 | /** 572 | * Whether or not to add a CLI framework. 573 | * 574 | * @return boolean 575 | */ 576 | public function withCliFramework(): bool 577 | { 578 | return $this->cliFramework !== null 579 | && $this->cliFramework !== ''; 580 | } 581 | 582 | /** 583 | * Get the entered CLI framework. 584 | * 585 | * @return string 586 | */ 587 | public function getCliFramework() 588 | { 589 | return $this->cliFramework; 590 | } 591 | 592 | /** 593 | * Set the CLI framework. 594 | * 595 | * @param string $cliFramework 596 | * 597 | * @return void 598 | */ 599 | public function setCliFramework($cliFramework) 600 | { 601 | $this->cliFramework = $cliFramework; 602 | } 603 | } 604 | -------------------------------------------------------------------------------- /src/stubs/CHANGELOG.stub: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). 5 | 6 | ## vMAJOR.MINOR.PATCH - {creation_date} 7 | - First release. 8 | -------------------------------------------------------------------------------- /src/stubs/CONDUCT.stub: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4/). 72 | -------------------------------------------------------------------------------- /src/stubs/CONTRIBUTING.PHPCS.stub: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Thanks for contributing to {project_lower}! Just follow these single guidelines: 4 | - You __MUST__ follow the PSR-2 coding standard. Please see [PSR-2](http://www.php-fig.org/psr/psr-2/) for more details. 5 | 6 | - Ensure the coding standard compliance before committing or opening pull requests by running `composer cs-fix` or `composer cs-lint` in the root directory of this repository. 7 | 8 | - You __MUST__ use [feature / topic branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows) to ease the merge of contributions. 9 | 10 | - You __MUST__ use the provided [commit message template]({git_message_path}), which follows the [rules](http://chris.beams.io/posts/git-commit/) described by Chris Beams. It can be configured via `composer configure-commit-template` prior to committing. 11 | -------------------------------------------------------------------------------- /src/stubs/CONTRIBUTING.stub: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | Thanks for contributing to {project_lower}! Just follow these single guidelines: 4 | - You __MUST__ follow the PSR-2 coding standard. Please see [PSR-2](http://www.php-fig.org/psr/psr-2/) for more details. 5 | 6 | - You __MUST__ use [feature / topic branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows) to ease the merge of contributions. 7 | 8 | - You __MUST__ use the provided [commit message template]({git_message_path}), which follows the [rules](http://chris.beams.io/posts/git-commit/) described by Chris Beams. It can be configured via `composer configure-commit-template` prior to committing. 9 | -------------------------------------------------------------------------------- /src/stubs/MAINTAINERS.stub: -------------------------------------------------------------------------------- 1 | Firstname Familyname (@githubhandle) 2 | -------------------------------------------------------------------------------- /src/stubs/Project.stub: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/stubs/README.CONDUCT.GITHUB.TEMPLATES.stub: -------------------------------------------------------------------------------- 1 | {project_upper} 2 | ================ 3 | [![Build Status](https://travis-ci.org/{vendor_lower}/{project_lower}.svg?branch=master)](https://travis-ci.org/{vendor_lower}/{project_lower}) 4 | 5 | This is where your library description should go. Try to limit it to a paragraph or two. 6 | 7 | #### Installation via Composer 8 | ``` bash 9 | $ composer require {vendor_lower}/{project_lower} 10 | ``` 11 | 12 | #### Running tests 13 | ``` bash 14 | $ composer test 15 | ``` 16 | 17 | #### License 18 | This library is licensed under the {license} license. Please see [LICENSE](LICENSE.md) for more details. 19 | 20 | #### Changelog 21 | Please see [CHANGELOG](CHANGELOG.md) for more details. 22 | 23 | #### Code of Conduct 24 | Please see [CONDUCT](CONDUCT.md) for more details. 25 | 26 | #### Contributing 27 | Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details. 28 | -------------------------------------------------------------------------------- /src/stubs/README.CONDUCT.stub: -------------------------------------------------------------------------------- 1 | {project_upper} 2 | ================ 3 | [![Build Status](https://travis-ci.org/{vendor_lower}/{project_lower}.svg?branch=master)](https://travis-ci.org/{vendor_lower}/{project_lower}) 4 | 5 | This is where your library description should go. Try to limit it to a paragraph or two. 6 | 7 | #### Installation via Composer 8 | ``` bash 9 | $ composer require {vendor_lower}/{project_lower} 10 | ``` 11 | 12 | #### Running tests 13 | ``` bash 14 | $ composer test 15 | ``` 16 | 17 | #### License 18 | This library is licensed under the {license} license. Please see [LICENSE](LICENSE.md) for more details. 19 | 20 | #### Changelog 21 | Please see [CHANGELOG](CHANGELOG.md) for more details. 22 | 23 | #### Code of Conduct 24 | Please see [CONDUCT](CONDUCT.md) for more details. 25 | 26 | #### Contributing 27 | Please see [CONTRIBUTING](CONTRIBUTING.md) for more details. 28 | -------------------------------------------------------------------------------- /src/stubs/README.GITHUB.TEMPLATES.stub: -------------------------------------------------------------------------------- 1 | {project_upper} 2 | ================ 3 | [![Build Status](https://travis-ci.org/{vendor_lower}/{project_lower}.svg?branch=master)](https://travis-ci.org/{vendor_lower}/{project_lower}) 4 | 5 | This is where your library description should go. Try to limit it to a paragraph or two. 6 | 7 | #### Installation via Composer 8 | ``` bash 9 | $ composer require {vendor_lower}/{project_lower} 10 | ``` 11 | 12 | #### Running tests 13 | ``` bash 14 | $ composer test 15 | ``` 16 | 17 | #### License 18 | This library is licensed under the {license} license. Please see [LICENSE](LICENSE.md) for more details. 19 | 20 | #### Changelog 21 | Please see [CHANGELOG](CHANGELOG.md) for more details. 22 | 23 | #### Contributing 24 | Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details. 25 | -------------------------------------------------------------------------------- /src/stubs/README.stub: -------------------------------------------------------------------------------- 1 | {project_upper} 2 | ================ 3 | [![Build Status](https://travis-ci.org/{vendor_lower}/{project_lower}.svg?branch=master)](https://travis-ci.org/{vendor_lower}/{project_lower}) 4 | 5 | This is where your library description should go. Try to limit it to a paragraph or two. 6 | 7 | #### Installation via Composer 8 | ``` bash 9 | $ composer require {vendor_lower}/{project_lower} 10 | ``` 11 | 12 | #### Running tests 13 | ``` bash 14 | $ composer test 15 | ``` 16 | 17 | #### License 18 | This library is licensed under the {license} license. Please see [LICENSE](LICENSE.md) for more details. 19 | 20 | #### Changelog 21 | Please see [CHANGELOG](CHANGELOG.md) for more details. 22 | 23 | #### Contributing 24 | Please see [CONTRIBUTING](CONTRIBUTING.md) for more details. 25 | -------------------------------------------------------------------------------- /src/stubs/Vagrantfile.stub: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | config.vm.box = "base" 16 | 17 | # Disable automatic box update checking. If you disable this, then 18 | # boxes will only be checked for updates when the user runs 19 | # `vagrant box outdated`. This is not recommended. 20 | # config.vm.box_check_update = false 21 | 22 | if Vagrant.has_plugin?("vagrant-cachier") 23 | config.cache.scope = :box 24 | end 25 | 26 | # Create a forwarded port mapping which allows access to a specific port 27 | # within the machine from a port on the host machine. In the example below, 28 | # accessing "localhost:8080" will access port 80 on the guest machine. 29 | # config.vm.network "forwarded_port", guest: 80, host: 8080 30 | 31 | # Create a private network, which allows host-only access to the machine 32 | # using a specific IP. 33 | # config.vm.network "private_network", ip: "192.168.33.10" 34 | 35 | # Create a public network, which generally matched to bridged network. 36 | # Bridged networks make the machine appear as another physical device on 37 | # your network. 38 | # config.vm.network "public_network" 39 | 40 | # Share an additional folder to the guest VM. The first argument is 41 | # the path on the host to the actual folder. The second argument is 42 | # the path on the guest to mount the folder. And the optional third 43 | # argument is a set of non-required options. 44 | # config.vm.synced_folder "../data", "/vagrant_data" 45 | 46 | # Provider-specific configuration so you can fine-tune various 47 | # backing providers for Vagrant. These expose provider-specific options. 48 | # Example for VirtualBox: 49 | # 50 | # config.vm.provider "virtualbox" do |vb| 51 | # # Display the VirtualBox GUI when booting the machine 52 | # vb.gui = true 53 | # 54 | # # Customize the amount of memory on the VM: 55 | # vb.memory = "1024" 56 | # end 57 | # 58 | # View the documentation for the provider you are using for more 59 | # information on available options. 60 | 61 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 62 | # such as FTP and Heroku are also available. See the documentation at 63 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 64 | # config.push.define "atlas" do |push| 65 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 66 | # end 67 | 68 | # Enable provisioning with a shell script. Additional provisioners such as 69 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 70 | # documentation for more information about their specific syntax and use. 71 | # config.vm.provision "shell", inline: <<-SHELL 72 | # sudo apt-get update 73 | # sudo apt-get install -y apache2 74 | # SHELL 75 | end 76 | -------------------------------------------------------------------------------- /src/stubs/appveyor.stub: -------------------------------------------------------------------------------- 1 | build: false 2 | clone_depth: 1 3 | platform: x86 4 | 5 | environment: 6 | matrix: 7 | - php_ver_target: {php_version} 8 | 9 | cache: 10 | - C:\php -> .appveyor.yml 11 | - C:\ProgramData\chocolatey\bin -> .appveyor.yml 12 | - C:\ProgramData\chocolatey\lib -> .appveyor.yml 13 | - '%LOCALAPPDATA%\Composer' 14 | 15 | init: 16 | - SET PATH=C:\php;%PATH% 17 | - SET COMPOSER_NO_INTERACTION=1 18 | - SET PHP=1 19 | - SET ANSICON=121x90 (121x90) 20 | - git config --global core.autocrlf input 21 | 22 | install: 23 | - IF EXIST C:\php (SET PHP=0) ELSE (mkdir C:\php) 24 | - cd C:\php 25 | # Enable Windows update service 26 | - ps: Set-Service wuauserv -StartupType Manual 27 | # Install PHP 28 | - ps: appveyor-retry cinst --params '""/InstallDir:C:\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') 29 | - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat 30 | - appveyor DownloadFile https://getcomposer.org/composer.phar 31 | - copy php.ini-production php.ini /Y 32 | - echo date.timezone="UTC" >> php.ini 33 | - echo extension_dir=ext >> php.ini 34 | - echo extension=php_openssl.dll >> php.ini 35 | - echo extension=php_curl.dll >> php.ini 36 | - echo extension=php_mbstring.dll >> php.ini 37 | - echo extension=php_fileinfo.dll >> php.ini 38 | - cd %APPVEYOR_BUILD_FOLDER% 39 | - composer update --no-progress --ansi 40 | 41 | test_script: 42 | - cd %APPVEYOR_BUILD_FOLDER% 43 | - composer test 44 | -------------------------------------------------------------------------------- /src/stubs/cli-script.stub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 3 | composer install' . PHP_EOL); 22 | exit(1); 23 | } 24 | -------------------------------------------------------------------------------- /src/stubs/composer/composer.phpunit.stub: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{vendor_lower}/{project_lower}", 3 | "description": "PHP project.", 4 | "keywords": [{keywords}], 5 | "license": "{license}", 6 | "authors": [ 7 | { 8 | "name": "{author_name}", 9 | "email": "{author_email}" 10 | } 11 | ], 12 | "require": { 13 | "php": ">={php_version}" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "{namespace}\\": "src/" 18 | } 19 | }, 20 | "autoload-dev": { 21 | "psr-4": { 22 | "{namespace}\\Tests\\": "tests/" 23 | } 24 | }, 25 | "minimum-stability": "stable", 26 | "config": { 27 | "sort-packages": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/stubs/composer/composer.stub: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{vendor_lower}/{project_lower}", 3 | "description": "PHP project.", 4 | "keywords": [{keywords}], 5 | "license": "{license}", 6 | "authors": [ 7 | { 8 | "name": "{author_name}", 9 | "email": "{author_email}" 10 | } 11 | ], 12 | "require": { 13 | "php": ">={php_version}" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "{namespace}\\": "src/" 18 | } 19 | }, 20 | "minimum-stability": "stable", 21 | "config": { 22 | "sort-packages": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/stubs/editorconfig.stub: -------------------------------------------------------------------------------- 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 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | 17 | [*.yml] 18 | indent_style = space 19 | indent_size = 2 20 | -------------------------------------------------------------------------------- /src/stubs/env.stub: -------------------------------------------------------------------------------- 1 | # Example .env 2 | EXAMPLE_KEY="example_value" # modify to your needs 3 | -------------------------------------------------------------------------------- /src/stubs/gitattributes.stub: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /src/stubs/github/ISSUE_TEMPLATE.stub: -------------------------------------------------------------------------------- 1 | | Q | A 2 | | ---------------- | ----- 3 | | Bug report? | yes/no 4 | | Feature request? | yes/no 5 | | BC break report? | yes/no 6 | | RFC? | yes/no 7 | | Version | x.y.z 8 | 9 | 14 | 15 | ### Expected behavior 16 | 17 | ### Actual behavior 18 | 19 | ### Steps to reproduce actual behavior 20 | -------------------------------------------------------------------------------- /src/stubs/github/PULL_REQUEST_TEMPLATE.stub: -------------------------------------------------------------------------------- 1 | | Q | A 2 | | ------------- | --- 3 | | Branch? | x.y.z or master 4 | | Bug fix? | yes/no 5 | | New feature? | yes/no 6 | | BC breaks? | yes/no 7 | | Deprecations? | yes/no 8 | | Tests pass? | yes/no 9 | | Fixes | #... 10 | | License | {license} 11 | 12 | Changes proposed in this pull request: 13 | 14 | 18 | -------------------------------------------------------------------------------- /src/stubs/gitmessage.stub: -------------------------------------------------------------------------------- 1 | Subject line 2 | 3 | # - Capitalise the subject line and do not end it with a period 4 | # - Use the imperative mood in the subject line 5 | # - Summarise changes in around 50 (soft limit, hard limit at 69) 6 | # characters or less in the subject line 7 | # - Separate subject line from body with a blank line 8 | Optional subject body 9 | # - Capitalise the subject body 10 | # - Use the subject body to explain what and why vs. how 11 | # - Wrap the subject body at 72 characters 12 | -------------------------------------------------------------------------------- /src/stubs/lgtm.stub: -------------------------------------------------------------------------------- 1 | approvals = 2 2 | pattern = "(?i)LGTM" 3 | -------------------------------------------------------------------------------- /src/stubs/licenses/apache-2.0.stub: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/stubs/licenses/gpl-2.0.stub: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {author_name} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /src/stubs/licenses/gpl-3.0.stub: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {author_name} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {author_name} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /src/stubs/licenses/mit.stub: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) {year} {author_name} 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. 22 | -------------------------------------------------------------------------------- /src/stubs/phpcs.stub: -------------------------------------------------------------------------------- 1 | in(__DIR__); 5 | 6 | $cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__; 7 | 8 | $rules = [ 9 | 'psr0' => false, 10 | '@PSR2' => true, 11 | ]; 12 | 13 | return PhpCsFixer\Config::create() 14 | ->setRules($rules) 15 | ->setFinder($finder) 16 | ->setCacheFile($cacheDir . '/.php_cs.cache'); 17 | -------------------------------------------------------------------------------- /src/stubs/phpspec.stub: -------------------------------------------------------------------------------- 1 | suites: 2 | main: 3 | namespace: {namespace} 4 | psr4_prefix: {namespace} 5 | src_path: src 6 | -------------------------------------------------------------------------------- /src/stubs/phpunit.stub: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | tests/ 15 | 16 | 17 | 18 | 19 | src/ 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/stubs/travis.phpcs.stub: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | notifications: 4 | email: 5 | on_success: never 6 | 7 | git: 8 | depth: 2 9 | 10 | matrix: 11 | include: 12 | {phpVersions} 13 | fast_finish: true 14 | 15 | cache: 16 | directories: 17 | - $HOME/.composer/cache 18 | - $HOME/.php-cs-fixer 19 | 20 | before_script: 21 | - travis_retry composer self-update 22 | - travis_retry composer install --no-interaction 23 | 24 | script: 25 | - if [[ $LINT = true ]]; then 26 | composer cs-lint; 27 | fi 28 | - composer test 29 | -------------------------------------------------------------------------------- /src/stubs/travis.stub: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | notifications: 4 | email: 5 | on_success: never 6 | 7 | git: 8 | depth: 2 9 | 10 | matrix: 11 | include: 12 | {phpVersions} 13 | fast_finish: true 14 | 15 | cache: 16 | directories: 17 | - $HOME/.composer/cache 18 | 19 | before_script: 20 | - travis_retry composer self-update 21 | - travis_retry composer install --no-interaction 22 | 23 | script: 24 | - composer test 25 | --------------------------------------------------------------------------------