Skip to content

Commit

Permalink
[PHP] Add gitignore to AbstractPhpCodegen (#765)
Browse files Browse the repository at this point in the history
* [PHP] Remove PHP related rules from root gitignore

After conversation with @ackintosh we've agreed that every PHP codegen
should create it's own `.gitignore`. Client libraries(SDKs) should ignore
`composer.lock` file while server stubs better do opposite.

* [PHP] Set .gitignore as default supporting file

* [PHP] Add default gitignore to Client SDK

* [PHP] Add default gitignore to Laravel

* [PHP] Add default gitignore to Lumen

* [PHP] Add default gitignore to Silex

Seems like issue #663 and pull request #681 missed this security script,
I've changed output path in bin/security/silex-petstore-server.sh.

* [PHP] Update Slim

* [PHP] Add default gitignore to Symfony

I've copied few old rules from root gitignore to local one. These rules
should be reviewed by original SymfonyCodegen authors.

* [PHP] Add default gitignore to Zend

* [PHP] Refresh Openapi3 client samples

* [PHP] Add refs to .gitignore templates collection
  • Loading branch information
ybelenko authored and wing328 committed Aug 20, 2018
1 parent b91c8e1 commit e605882
Show file tree
Hide file tree
Showing 25 changed files with 2,114 additions and 17 deletions.
15 changes: 0 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,6 @@ samples/client/petstore/java/jersey2-java6/project/
samples/client/petstore/java/jersey2-java8/project/
samples/client/petstore/java/jersey2/project/

#PHP
samples/client/petstore/php/OpenAPIToolsClient-php/composer.lock
samples/client/petstore/php/OpenAPIToolsClient-php/vendor/
samples/client/petstore/silex/SwaggerServer/composer.lock
samples/client/petstore/silex/SwaggerServer/venodr/
**/vendor/
**/composer.lock

#PHP-Symfony
samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/cache/
samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/logs/

#PHP-laravel
samples/server/petstore/php-laravel/node_modules

# Perl
samples/client/petstore/perl/deep_module_test/

Expand Down
2 changes: 1 addition & 1 deletion bin/security/silex-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-silex -o samples/server/petstore-security-test/silex $@"
ags="generate -t modules/openapi-generator/src/main/resources/php-silex -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g php-silex -o samples/server/petstore-security-test/silex/SwaggerServer $@"

java $JAVA_OPTS -jar $executable $ags
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;

import io.swagger.v3.oas.models.media.*;
Expand Down Expand Up @@ -238,6 +239,9 @@ public void processOpts() {

// apache v2 license
// supportingFiles.add(new SupportingFile("LICENSE", "", "LICENSE"));

// all PHP codegens requires Composer, it means that we need to exclude from SVN at least vendor folder
supportingFiles.add(new SupportingFile(".gitignore", "", ".gitignore"));
}

public String getPackageName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public PhpSilexServerCodegen() {
supportingFiles.add(new SupportingFile("composer.json", "", "composer.json"));
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess"));

// remove this line when this class extends AbstractPhpCodegen
supportingFiles.add(new SupportingFile(".gitignore", "", ".gitignore"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess"));
supportingFiles.add(new SupportingFile(".gitignore", "", ".gitignore"));
supportingFiles.add(new SupportingFile("AbstractApiController.mustache", toSrcPath(invokerPackage, srcBasePath), "AbstractApiController.php"));
supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php"));
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
Expand Down
8 changes: 8 additions & 0 deletions modules/openapi-generator/src/main/resources/lumen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ref: https://github.com/github/gitignore/blob/master/Laravel.gitignore

vendor/
node_modules/
npm-debug.log
yarn-error.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ref: https://github.com/github/gitignore/blob/master/Symfony.gitignore

# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep

# Email spool folder
/app/spool/*

# Cache, session files and logs (Symfony3)
/var/cache/*
/var/logs/*
/var/sessions/*
!var/cache/.gitkeep
!var/logs/.gitkeep
!var/sessions/.gitkeep

# Parameters
/app/config/parameters.yml
/app/config/parameters.ini

# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/

# Assets and user uploads
/web/bundles/
/web/uploads/

# PHPUnit
/app/phpunit.xml
/phpunit.xml

# Build data
/build/

# Composer PHAR
/composer.phar

# Backup entities generated with doctrine:generate:entities command
**/Entity/*~

# Embedded web-server pid file
/.web-server-pid

# From root gitignore
/Tests/cache/
/Tests/logs/
8 changes: 8 additions & 0 deletions modules/openapi-generator/src/main/resources/php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
26 changes: 26 additions & 0 deletions modules/openapi-generator/src/main/resources/ze-ph/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ref: https://github.com/github/gitignore/blob/master/ZendFramework.gitignore

# Composer files
composer.phar
vendor/

# Local configs
config/autoload/*.local.php

# Binary gettext files
*.mo

# Data
data/logs/
data/cache/
data/sessions/
data/tmp/
temp/

#Doctrine 2
data/DoctrineORMModule/Proxy/
data/DoctrineORMModule/cache/

# Legacy ZF1
demos/
extras/documentation
8 changes: 8 additions & 0 deletions samples/client/petstore-security-test/php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
8 changes: 8 additions & 0 deletions samples/client/petstore/php/OpenAPIClient-php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
8 changes: 8 additions & 0 deletions samples/server/petstore-security-test/lumen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
2 changes: 2 additions & 0 deletions samples/server/petstore-security-test/php-slim/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore

composer.phar
/vendor/

Expand Down
Loading

0 comments on commit e605882

Please sign in to comment.