Laravel Queue Cache not updating - laravel

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

Related

When l renamed layouts/admin.blade.php I got layouts.app ref error

Making adminarea in Laravel 8 / livewire 2.5 / tailwindcss: 2.2 app
I renamed file.
resources/views/layouts/app.blade.php
into
resources/views/layouts/admin.blade.php
and fixed in View/Components/AppLayout.php :
public function render()
{
return view('layouts.admin');
}
and run commands :
php artisan config:cache
php artisan route:cache
php artisan cache:clear
php artisan view:clear
php artisan clear-compiled
composer dump-autoload
but I still got error :
View [layouts.app] not found. (View: /Project/vendor/livewire/livewire/src/Macros/livewire-view-component.blade.php)
Looks like there is some default "app" ref, which raise this error?
Which is valid way t5o split my app into several layouts?
Thanks!

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

Laravel - Is the cache:clear command will clear config cache also?

I use Laravel 5.8, and as we know, there are 3 type of cache in Laravel
Config cache (php artisan config:cache)
Route cache (php artisan route:cache)
View cache (php artisan view:cache)
.
So, in my Laravel app, I use Cache::remember('mycachetoday', $seconds, function(){})...
In order to clear the mycachetoday, i must run php artisan cache:clear, right?
But I wonder if I run php artisan cache:clear, will the config, route, and view cache be cleared also?
Thanks
You can try
php artisan config:cache
The config cache file will be store in bootstrap/cache directory.
When you run
php artisan cache:clear
It will only clear the datas that you store by Cache. The config cache file still in bootstrap/cache.
After you run php artisan config:clear, the file will be deleted from bootstrap/cache.
Check the ClearCommand source code, there is no code that delete any config/route/view cache file in bootstrap/cache, and only clear the application cache.
/**
* Execute the console command.
*
* #return void
*/
public function handle()
{
$this->laravel['events']->dispatch(
'cache:clearing', [$this->argument('store'), $this->tags()]
);
$successful = $this->cache()->flush();
$this->flushFacades();
if (! $successful) {
return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
}
$this->laravel['events']->dispatch(
'cache:cleared', [$this->argument('store'), $this->tags()]
);
$this->info('Application cache cleared!');
}
Check the ConfigClearCommand source code, it will delete the config cache file.
/**
* Execute the console command.
*
* #return void
*/
public function handle()
{
$this->files->delete($this->laravel->getCachedConfigPath());
$this->info('Configuration cache cleared!');
}
To clear everything, you can do php artisan optimize:clear. This will result in:
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!
Regards!

Impossible to create the root directory - swagger with 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

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

Resources