Impossible to create the root directory - swagger with laravel - laravel

I'm trying to add swagger documentation on my laravel rest API. First of all, I have installed the composer require "darkaonline/l5-swagger" and then composer require zircote/swagger-php then I have run
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
but the follwuing error occures.
League\Flysystem\Exception : Impossible to create the root directory "".
at C:\xampp\htdocs\landing-temp\vendor\league\flysystem\src\Adapter\Local.php:112
108| clearstatcache(false, $root);
109|
110| if ( ! is_dir($root)) {
111| $errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : '';
> 112| throw new Exception(sprintf('Impossible to create the root directory "%s". %s', $root, $errorMessage));
113| }
114| }
115| }
116|
Exception trace:
1 League\Flysystem\Adapter\Local::ensureDirectory()
C:\xampp\htdocs\landing-temp\vendor\league\flysystem\src\Adapter\Local.php:78
2 League\Flysystem\Adapter\Local::__construct()
C:\xampp\htdocs\landing-temp\vendor\laravel\framework\src\Illuminate\Foundation\Console\VendorPublishCommand.php:235
Please use the argument -v to see more details.
What should I do to solve this problem?

For Laravel 8. Documentation says that it uses a package auto-discovery feature. But it's not true.
You have to add to your config/app.php in providers section:
L5Swagger\L5SwaggerServiceProvider::class,
Then, you have to run the
php artisan config:cache
And only then, you can run the
php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'

Versions: Laravel 6, darkaonline/l5-swagger : "6."*
Just add this line in your .env file
L5_SWAGGER_GENERATE_ALWAYS=true
Then run this command
php artisan config:cache
At the end run this command
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
This worked for me :)

composer require darkaonline/l5-swagger
For use of #SWG annotation we are going to install the following package,
composer require zircote/swagger-php
and then run this artisan command,
php artisan vendor:publish --provider 'L5Swagger\L5SwaggerServiceProvider'

check your read/write permissions:
https://laravel.com/docs/8.x/installation#directory-permissions
as root:
cd /dir/to/your/laravel-app
chmod -R 750 .
chmod -R 770 ./storage
chmod -R 770 ./bootstrap/cache
And what also worked me after I checked the permissions: php artisan config:cache source or for laravel versions > 7 php artisan optimize

Related

How to create a new migration file under laravel-modules?

reading how laravel-modules works for laravel 6
https://nwidart.com/laravel-modules/v6/advanced-tools/artisan-commands
I did not find how to create a new migration file. I tried 2 ways and failed both :
root#95e2f26acdf8:/app/Modules/Opportunities# php artisan make:migration leads_table_add_test_id_fields --table=leads
Could not open input file: artisan
root#95e2f26acdf8:/app/Modules/Opportunities# php artisan make:migration Opportunities leads_table_add_test_id_fields --table=leads
Could not open input file: artisan
root#95e2f26acdf8:/app/Modules/Opportunities# cd ../
root#95e2f26acdf8:/app/Modules# cd ../
root#95e2f26acdf8:/app# php artisan make:migration Opportunities leads_table_add_test_id_fields --table=leads
Too many arguments, expected arguments "command" "name".
MODIFIED :
Yes, that command
php artisan module:make-migration leads_table_add_test_fields Opportunities
works ok. But I tried to add --table= option as
php artisan module:make-migration leads_table_add_test_fields Opportunities --table=opportunities
but got error :
The "--table" option does not exist.
?
Which way is correct ?
I think you should run:
php artisan module:make-migration add_field_to_leads_table Opportunities

no php artisan commands are working after new migration

I am new to laravel .
Following tutorial videos on laracast,i made a new migration (cmd command) like following
php artisan make:migration delete_title_from_posts_table
which gave me the message
Created Migration: 2020_02_05_185721_delete_title_from_posts_table
after that no php artisian command is working in cmd.
Any command i run gives me the following error
In Container.php line 805:
Target class [db] does not exist.
In Container.php line 803:
Class db does not exist
what would be causing this?
my laravel app version=6.2 and php version=7.3.5 on Win10 64-bit.
similar questions i already viewed,not working for me
artisan-commands-not-working-after-composer-update
in-container-php-line-805-target-class-db-does-not-exist
Since it's a facade, add this to the top of the class to make it work:
use DB;
Or use full namespace:
$tables = \DB::table...
run these commands steps by step:
composer dump-autoload clean up all compiled files and their paths
composer update --no-scripts Skips execution of scripts defined in composer.json
composer update update your project's dependencies

Laravel Queue Cache not updating

I have used Laravel queues in my application and when i try to run
php artisan queue:restart
it gives me following exception:
ErrorException : file_put_contents(/storage/framework/cache/data/ee/2f/ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90): failed to open stream: No such file or directory
at /var/www/html/asd/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
118| * #return int
119| */
120| public function put($path, $contents, $lock = false)
121| {
> 122| return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
123| }
124|
125| /**
126| * Prepend to a file.
Exception trace:
1 file_put_contents("/var/www/html/asd/storage/framework/cache/data/ee/2f/ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90", "9999999999i:1558912298;")
/var/www/html/asd/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
2 Illuminate\Filesystem\Filesystem::put("/var/www/html/asd/storage/framework/cache/data/ee/2f/ee2f842aa7bb1f53edf3a2ed2c09a1807ffa6c90", "9999999999i:1558912298;")
/var/www/html/asd/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php:65
Please use the argument -v to see more details.
I have tried running following commands but to no avail:
composer dump-autoload
php artisan optimize
php artisan clear-compiled
php artisan cache:clear
php artisan view:clear
php artisan route:cache
I am not able to reflect changes made to my application logic that is in queue handlers, any help in this regard is much appreciated.
You forgot to run php artisan config:cache with the other commands
I read somewhere else that you could try
chmod 775 -R storage

Getting messages feature in Debugbar to work in Laravel

I've installed Debugbar for Laravel as described in the steps on the website https://laravel-news.com/laravel-debugbar; and tried to make use of the Messages feature by placing the following below in my code.
Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');
But when I run my website, I get the error message from Laravel saying:
1/1
FatalErrorException in HistoryController.php line 11:
Class 'App\Http\Controllers\Debugbar' not found
I have to go like /Debugbar::info(...) or put use Debugbar at the top of my code to not get the error message. Why can't I use it straight like Debugbar::info(...)?
To be able to reference the facade without prefixing it with \ you should add
use Barryvdh\Debugbar;
to the top of your controller.
after adding setting code in /config/app.php
you can use it as a facade
app('debugbar')->info('info message');
or
debugbar()->info('message');
no need use
I think you should try this :
first you add below code in config/app.php
in provider section
'Barryvdh\Debugbar\ServiceProvider',
in aliases section
'Debugbar' => 'Barryvdh\Debugbar\Facade',
after you should clear the cache like:
php artisan config:cache
php artisan cache:clear
php artisan config:clear
Hope this work for you !
Firstly, Go to the terminal and install by typing:-
composer require barryvdh/laravel-debugbar
In second step, Check your laravel verision:-
php artisan --version
In third if your laravel version is greater than 5(Laravel 5.x)
add the ServiceProvider to the providers array in config/app.php
Barryvdh\Debugbar\ServiceProvider::class,
add this to your facades in app.php:
'Debugbar' => Barryvdh\Debugbar\Facade::class,
Finally, published vendor configuration by command:-
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
After vendor published clear cache,route,view by command
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan dump-autoload -o

How to use artisan to make views in laravel 5.1

I have been looking in the docs for a solution to make views with basic CURD operations but without much success.
I guess this might be pretty simple, but am missing something or not looking hard enough.
i can make models and controllers using the below artisan commands
php artisan make:model modelName
php artisan make:controller controllerName
But how do we make the basic CURD views. something like
php artisan make:views
cant find any doc for this. Please help
At the time of writing, there isn't a way to create views via artisan without writing your own command or using a third party package. You could write your own as already suggested or use sven/artisan-view.
if you are using laravel 5.1 or 5.2 this gist can help you make:view command just create command copy and paste the code from gist.
Step 1:
php artisan make:command MakeViewCommand
Step 2:
copy class from this gist
https://gist.github.com/umefarooq/ebc617dbf88260db1448
Laravel officially doesn't have any Artisan cammands for views.
But you could add third party plugins like Artisan View
Here's the link Artisan View
After adding this plugin to your project by the guide provided here you should be able to perform following cammands :
Create a view 'index.blade.php' in the default directory
$ php artisan make:view index
Create a view 'index.blade.php' in a subdirectory ('pages')
$ php artisan make:view pages.index
Create a view with a different file extension ('index.html')
$ php artisan make:view index --extension=html
There is very easy way to create a view(blade) file with php artisan make:view {view-name} command using Laravel More Command Package.
First Install Laravel More Command
composer require theanik/laravel-more-command --dev
Then Run
php artisan make:view {view-name}
For example
It create index.blade.php in resource/views directory
php artisan make:view index
It create index.blade.php in resource/views/user directory
php artisan make:view user/index
Thank you.
In v5.4 you need to create the command with:
php artisan make:command MakeView
and before you can use it, it must be registered in App/Console/Kernel like
protected $commands = [
Commands\MakeView::class
];
then you make a view like: php artisan make:view posts/create
To create a view (blade) file through command in laravel 8:
composer require theanik/laravel-more-command --dev
php artisan make:view abc.blade.php
You can install sven/artisan-view package to make view from CMD, to install package write this command:
composer require sven/artisan-view --dev
After installing it, you can make a single view or folder with all views that contain {index-create-update-show}
To make a single file we using this command:
php artisan make:view Name_of_view
For example
php artisan make:view index
To make a folder that contain all resources index - create - update - show write name of folder that contain all this files for example:
php artisan make:view Name_of_Folder -r
For example:
php artisan make:view blog -r
-r is a shorthand for --resource you can write full name or shorthand to make resource.
you can extend yields from master page if master page inside in directory layouts we write command sith this format
php artisan make:view index --extends=layouts.master --with-yields
layouts is a directory this directory may be with a different name in your project the idea is name_of_folder/master_page that you want to extend yields from it.
For more view docs

Resources