appointer / swaggervel

Swagger for Laravel
70 stars 40 forks source link

Running `php artisan vendor:publish` fails #1

Closed gandra closed 7 years ago

gandra commented 7 years ago

Running php artisan vendor:publish fails with error:

$ php artisan vendor:publish PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Undefined constant 'Jlapp\Swaggervel\SwaggervelServiceProvider' in D:\www\learn-laravel\kibernum-dnc-api\config\app.php:169 Stack trace:

0 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(60): require()

1 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(38): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\F

oundation\Application), Object(Illuminate\Config\Repository))

2 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(203): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))

3 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)

4 D:\www in D:\www\learn-laravel\kibernum-dnc-api\config\app.php on line 169

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Undefined constant 'Jlapp\Swaggervel\SwaggervelServiceProvider' in D:\www\learn-laravel\kibernum-dnc-api\config\app.php:169 Stack trace:

0 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(60): require()

1 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\LoadConfiguration.php(38): Illuminate\Foundation\Bootstrap\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\F

oundation\Application), Object(Illuminate\Config\Repository))

2 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(203): Illuminate\Foundation\Bootstrap\LoadConfiguration->bootstrap(Object(Illuminate\Foundation\Application))

3 D:\www\learn-laravel\kibernum-dnc-api\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)

4 D:\www in D:\www\learn-laravel\kibernum-dnc-api\config\app.php on line 169

I am using laravel 5.3 and php 7.1 on windows 7.

fgreinus commented 7 years ago

Hey :).

Did you add the ServiceProvider correctly? Seems like you missed to add ::class within the app.php config file.

You have to add Jlapp\Swaggervel\SwaggervelServiceProvider::class, to the app.php.

Update: I modified the README file, because the ::class was missing in there, too.

gandra commented 7 years ago

Thanks! I had did it all from beginning and now works. In your docs should be addedd following line at the beggining for the installation: composer require "appointer/Swaggervel" --dev

I had played with different swagger packages and somehow was in inconsistent state. I have a problem to find decent swagger package for laravel. Can you help me to make some API documentation where will be demonstrated all relevant API docs:

I have created demo project for this purpose: https://github.com/gandra/appointer-swaggervel-laravel-demo/blob/master/app/Http/Controllers/Api/AnimalsController.php

fgreinus commented 7 years ago

Hey, i added the line to the readme file.

Yeah, finding good examples really is not that easy - I had to figure everything out by myself. Maybe I have time to throw in some examples. Thanks for the input!

By the way: It seems that i don't have access to the file you linked :(.

gandra commented 7 years ago

Sorry man, I have put wrong link ... indeed namespace api was wrongly commited as app ... try it again https://github.com/gandra/appointer-swaggervel-laravel-demo/blob/master/app/Http/Controllers/Api/AnimalsController.php

fgreinus commented 7 years ago

I attached several examples from an existing project of mine. Maybe this is helpful to you.

gandra commented 7 years ago

Thanks man!

If you find time can you add some examples regarding to security and authentication?

For example where I could add SecurityScheme annotation to be used in all other parts of app?

 * @SWG\SecurityScheme(
 *   securityDefinition="api_key",
 *   type="apiKey",
 *   in="header",
 *   name="api_key"
 * )
 *
 * @SWG\SecurityScheme(
 *   securityDefinition="myapp_auth",
 *   type="oauth2",
 *   authorizationUrl="http://my.url.com/oauth/dialog",
 *   flow="implicit",
 *   scopes={
 *     "read:data": "read data",
 *     "write:data": "modify data"
 *   }
 * )

Maybe in some parent controller?

And is it possible to add multiple schemes for the same project?

fgreinus commented 7 years ago

In my case i added them in the Controller.php - the Class that is extended by all Controllers within me application. But you could also create a new .php file to place the annotations in there - php-swagger just scans your whole directory with all files in it - doesn't matter where you actually place the annotations.

gandra commented 7 years ago

Thanks!