-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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][LARAVEL] initial PHP-laravel integration #574
Conversation
@renepardon thanks for the PR. I've cc'd the technical committee below for review: @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) |
👀 |
.gitignore
Outdated
@@ -96,6 +96,9 @@ samples/client/petstore/silex/SwaggerServer/venodr/ | |||
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 | |||
samples/server/petstore/php-laravel/vendor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is unnecessary as 'vendor' is ignored here.
import org.slf4j.LoggerFactory; | ||
|
||
|
||
public class PhpLaravelServerCodegen extends AbstractPhpCodegen implements CodegenConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implements CodegenConfig
is unnecessary as AbstractPhpCodegen implements CodegenConfig.
@ackintosh ok, have to add more laravel specific files. Will do so. The additional vendor/* will be removed within .gitignore and CodegenConfig implementation is also removed with next commit. |
As adding a new generator isn't breaking changes, let's change the target branch |
Ok, will solve the conflict as well with the new push. Changed PR to master already. |
@ackintosh i've encountered a problem. Maybe you had this one before with other generators for PHP: This is part of a generated *.php file: /**
* post fakeOuterBooleanSerialize
* Summary:
* Notes: Test serialization of outer boolean types
* Output-Formats: [*/*]
*/ Problem is, that the output format seems to be undefined and therefore it breaks the PHP comment. |
/**
* post fakeOuterBooleanSerialize
* Summary:
* Notes: Test serialization of outer boolean types
* Output-Formats: [*/*]
*/ Please refer to here ( |
This PR was started from Do you need help with sorting out the commits?
This will work, unless you need some changes from 05f177b |
@jmini thank you for your information. I've updated the source, created a new branch called php-laravel-master out of the master branch, cherry-picked my two commits and pushed the changes. A force-push resulted in a build failure (as you can see above) and a message telling me: $ git push -f fork php-laravel
Everything up-to-date |
…for those unfamilar with laravel to get started quickly
|
I have fetched your two branches locally:
(the name of the my remote pointing to your fork is called I would say that your commit 16a47f1 is a good candidate for this pr. Please force push it to your
(assuming that the name of the remote pointing to I have the feeling that your are really close to the goal. If you want me to do it, please tell me. If you have the option "Allow edits from maintainers" is set in GitHub, then I might be able to do it for you. But it might not be necessary, since your are so close. For the moment you still have |
I have "Allow edits from maintainers" enabled from the very beginning :) I pushed the requested commit: https://github.com/renepardon/openapi-generator/commits/php-laravel and also the samples. Everything should be done now i guess. |
The PR is ready for review, from a Git point of view, it can be merged to master. |
So here is what I did to help you removing the I have fetch both branches of yours:
Because I later override your I have taken 16a47f1 as root of my work (in order not to have the merge commit 5e20451 that created the problem). Then I cherry-picked 7622b37 (which is now 2a11fc4) And I have forced pushed my local HEAD to override your I hope it is clear now. As I demonstrated, nothing is lost, so I can revert my changes if you do not agree with it. Because of the force-push, if you want to add additional to the PR branch, I recommend you to fetch the changes from your fork. And then to reset you local Depending on how you have configured your git client, just doing a pull might create a not desired merge commit. |
@jmini Thanks for the follow-up! ✨ |
@renepardon Could you fix the path configuration as $ php artisan serve
Laravel development server started: <http://127.0.0.1:8000>
...
...
|
@jmini wow, very impressive! Thank you very much for removing this stuff. @ackintosh this is by intention of the laravel framework. Have a look at the corresponding service provider: https://github.com/renepardon/openapi-generator/blob/2a11fc491364971480a03304cfb7090b8d81a324/modules/openapi-generator/src/main/resources/php-laravel/app/Providers/RouteServiceProvider.php#L68 The only thing we could do is, to create another routes file (e.g. generated.php) and use this for the routes generated by the codegen. But API routes are expected to have the api prefix within a laravel application. So what do you suggest to do here? @taylorotwell what do you think? |
And is there an easier way to copy a complete folder of "static" assets/files recursively from resources folder to the output folder rather than copying all the individual files? |
Oh... 👀 💦 How about modifying the https://readouble.com/laravel/5.6/en/routing.html
protected function mapApiRoutes()
{
- Route::prefix('api')
+ Route::prefix('')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
} |
Yeah, we can indeed do so. So i will remove the prefix with the next commit! Do you know why the models aren't generated? (out of model.mustache) @ackintosh |
modelPackage = "models"; | ||
|
||
// template files want to be ignored | ||
modelTemplateFiles.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@renepardon please remove this line to have the model files auto-generated.
cc @ackintosh
Ok, changes done. @ackintosh Btw.:
|
Wow, amazing! 😄✨ Thanks for the updates! I'll have a look. |
The generated server works fine! but there's one thing that bothers me, the generated models have syntax error: $ pwd
~/openapi-generator-1/samples/server/petstore/php-laravel/lib
$ php -l app/Models/AdditionalPropertiesClass.php
Parse error: syntax error, unexpected '.', expecting '{' in app/Models/AdditionalPropertiesClass.php on line 5
Errors parsing app/Models/AdditionalPropertiesClass.php It caused by the change: 606cf90#diff-412b73e206d04f5e7da08a3f11ee8038R99 , |
@renepardon to shorten the build time, you may try "mvn clean package -DskipTests" and let the CIs (e.g. Travis, CircleCI, etc) run the tests later. |
@wing328 good to know. But 30s is ok. Would have helped me before on the old machine. |
Hi folks, can this be merged into master for a beta release? |
Would be nice to receive feedback here, yes :) |
If no further question/feedback on this PR, we'll merge it into master and ask developers for feedback. |
@renepardon thanks for contributing the PHP Laravel generator. I'll send out a tweet tomorrow to promote it. |
…nAPITools#574) * feat (PHP LARAVEL) 8417: initial PHP-laravel codegen integration * feat (PHP LARAVEL) 8417: code review adjustments * feat (PHP LARAVEL) 8417: fix typos; add missing files; adjust readme for those unfamilar with laravel to get started quickly * feat (PHP LARAVEL) 8417: add sample petstore server * feat (PHP LARAVEL) 8417: adjust route service provdider and model generation
PR checklist
./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\
.master
,3.1.x
,4.0.x
. Default:master
.Description of the PR
I've created the server stub generation for PHP laravel as requested in this ticket: swagger-api/swagger-codegen#8417
And wrote with @wing328 about this. Hopefully everything is implemented as expected. In the future I will maintain the template and also add some more laravel specific stuff like Request-Classes and models.