Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] Decommission "packagePath", add new option "packageName" #681

Merged
merged 9 commits into from
Aug 6, 2018

Conversation

wing328
Copy link
Member

@wing328 wing328 commented Jul 29, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

  • Decommission "packagePath"
  • Users will need to use -o (--output) to control the destination folder instead to make it consistent with other generators
  • add new option "packageName"

To close #663

cc @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) @ybelenko (2018/07)

Copy link
Contributor

@ybelenko ybelenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used getPackagePath method in

supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md"));
supportingFiles.add(new SupportingFile("composer.mustache", getPackagePath(), "composer.json"));
supportingFiles.add(new SupportingFile("index.mustache", getPackagePath(), "index.php"));
supportingFiles.add(new SupportingFile(".htaccess", getPackagePath(), ".htaccess"));
supportingFiles.add(new SupportingFile(".gitignore", getPackagePath(), ".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", getPackagePath(), "phpunit.xml.dist"));

You should change it too to keep all codegens consistent.

@wing328
Copy link
Member Author

wing328 commented Jul 31, 2018

@ybelenko what about keeping getPackagePath() or packagePath in all PHP server generators and put the following in the constructor instead?

        packagePath = ""; // empty packagePath (top folder)

so that the package path (root folder) can be changed easily by the users if they need to customize it somehow?

@ybelenko
Copy link
Contributor

@wing328 It was my first approuch. I don't have full knowledge of your path generation, but this way I can generate code in a specific folder. I think we need to ask @ackintosh about that.

@wing328
Copy link
Member Author

wing328 commented Jul 31, 2018

@ybelenko sure let's wait for @ackintosh to review.

Btw, the following approach is already used in other PHP server generators:

        packagePath = ""; // empty packagePath (top folder)

@ackintosh
Copy link
Contributor

I think packagePath = "" is good idea. 💡

It sets the destination to root folder as default and be able to change if user want.

@wing328
Copy link
Member Author

wing328 commented Aug 2, 2018

@ackintosh thanks for the feedback. I'll change the rest accordingly.

@wing328 wing328 changed the title Do not use "packagePath" when setting PHP file path [PHP] Decommission "packagePath", add new option "packageName Aug 4, 2018
@wing328 wing328 changed the title [PHP] Decommission "packagePath", add new option "packageName [PHP] Decommission "packagePath", add new option "packageName" Aug 4, 2018
@wing328
Copy link
Member Author

wing328 commented Aug 4, 2018

@ybelenko @ackintosh I've decommissioned packagePath and add a new option "packageName". The samples are exactly the same as before. Please review when you've time.

Copy link
Contributor

@ackintosh ackintosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a -o target which should be fixed. 👀

https://github.com/ackintosh/openapi-generator-1/blob/27426f7b522c1b55f6ebe6c90d41d77e3c7ab589/bin/openapi3/php-silex-petstore-server.sh#L30

samples/server/petstore/php-silex -> samples/server/petstore/php-silex/OpenAPIServer

@wing328
Copy link
Member Author

wing328 commented Aug 5, 2018

@ackintosh good catch. Fixed via 0d45184

Copy link
Contributor

@ackintosh ackintosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 👍

@wing328
Copy link
Member Author

wing328 commented Aug 5, 2018

@ybelenko can you merge it if it looks good to you? Thanks

@ybelenko
Copy link
Contributor

ybelenko commented Aug 5, 2018

Now I don't understand what we need packageName option for? We don't use it in path construction.

The only reason I can imagine for packageName("GeneratedPetstore" packageName as example):

/**
 * FakeApi Class Doc Comment
 * PHP Version 5
 *
 * @category Class
 * @package  GeneratedPetstore
 * @author   OpenAPI Generator team
 */
class FakeApi {

Do we keep packageName option to avoid breaking changes as fallback solution?
Or do you expect that user wants to use packageName in mustaches somehow?

The main package name for classes. e.g. GeneratedPetstore

If I understand this description correct, then mustache should look like:

class {{packageName}}{{classname}}

and result:

class GeneratedPetstoreFakeApi

In total packageName is a prefix to generated class names, isn't it?

@wing328
Copy link
Member Author

wing328 commented Aug 6, 2018

@wing328 wing328 merged commit c116c8f into master Aug 6, 2018
@wing328 wing328 deleted the php_output branch August 6, 2018 10:12
@wing328
Copy link
Member Author

wing328 commented Aug 6, 2018

Upgrade Note

The packagePath option has been deprecated. Please use -o or --output to specify the output folder.

To specify the package name in the auto-generated README.md, please use the new option packageName instead.

ybelenko added a commit to ybelenko/openapi-generator that referenced this pull request Aug 7, 2018
Seems like issue OpenAPITools#663 and pull request OpenAPITools#681 missed this security script,
I've changed output path in bin/security/silex-petstore-server.sh.
wing328 pushed a commit that referenced this pull request Aug 20, 2018
* [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
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
…PITools#681)

* remove packagePath from php file location, use -o instead

* fix php symfony top folder

* restore pacakgePath

* update php laraavel samples

* remove packagePath from PHP generator

* add new silex files

* update window batch - php silex

* fix openapi3 silex script
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* [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 OpenAPITools#663 and pull request OpenAPITools#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PHP] Generate SDK into root directory not into a folder
3 participants