[PHP] Add gitignore to AbstractPhpCodegen (#765)

* [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
This commit is contained in:
Yuriy Belenko 2018-08-20 09:16:01 +05:00 committed by William Cheng
parent b91c8e17a7
commit e605882451
25 changed files with 2114 additions and 17 deletions

15
.gitignore vendored
View File

@ -93,21 +93,6 @@ samples/client/petstore/java/jersey2-java6/project/
samples/client/petstore/java/jersey2-java8/project/ samples/client/petstore/java/jersey2-java8/project/
samples/client/petstore/java/jersey2/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 # Perl
samples/client/petstore/perl/deep_module_test/ samples/client/petstore/perl/deep_module_test/

View File

@ -27,6 +27,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # 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" 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 java $JAVA_OPTS -jar $executable $ags

View File

@ -24,6 +24,7 @@ import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen; import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.media.*;
@ -238,6 +239,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
// apache v2 license // apache v2 license
// supportingFiles.add(new SupportingFile("LICENSE", "", "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() { public String getPackageName() {

View File

@ -116,6 +116,9 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
supportingFiles.add(new SupportingFile("composer.json", "", "composer.json")); supportingFiles.add(new SupportingFile("composer.json", "", "composer.json"));
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php")); supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess")); supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess"));
// remove this line when this class extends AbstractPhpCodegen
supportingFiles.add(new SupportingFile(".gitignore", "", ".gitignore"));
} }
@Override @Override

View File

@ -113,7 +113,6 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json")); supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php")); supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess")); 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("AbstractApiController.mustache", toSrcPath(invokerPackage, srcBasePath), "AbstractApiController.php"));
supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php")); supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php"));
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist")); supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
composer.phar composer.phar
/vendor/ /vendor/

View File

@ -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/

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
composer.phar composer.phar
/vendor/ /vendor/

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
composer.phar composer.phar
/vendor/ /vendor/

View File

@ -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/

View File

@ -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