Laravel log max file is not working - php

I am using laravel 5.2, I just deployed my code on server. I am using laravel logs on the daily basis and so in the confg/app.php i added these two lines
'log' => 'daily'
'log_max_files' => 15
But it is not keeping the logs of 15 days. It is always keeping the logs of last 5 days only which is default file size. Am i missing something to add..?

First of all you should run
php artisan config:cache
to cache your configuration.
In addition you should run
php artisan queue:restart
to make sure your queue workers will see the changes.
Additionally you should make sure there are valid permissions to log files to make it possible to delete them.

You have to run this command on your terminal
php artisan config:cache

Related

Laravel Auth Session logs me out after a period of time

Users in my application are getting logged out after a period of time although i have set the environment variable SESSION_LIFETIME = 525600
There are 100+ concurrent users in the application
The SESSION_DRIVER is set to file, i have read that changing to database and creating the php artisan session:table migration will make it work.
What could be the problem?
**Edit
Locally this does not happen.
So changing the SESSION_DRIVER = database and using php artisan session:table fixed the issue and now everything works as expected.

Why aren't my changes to the scheduler in Laravel being reflected?

I am working on updating the schedule function in my Kernel.php file. I have versions of this file locally and on a production instance. There is a $schedule->call function that was set to run 4 different functions every 5 minutes. One of those functions is outdated and shouldn't be run anymore, so I commented it out locally and in the production instance.
I have a database table that logs the name of each function each time they are ran. When I checked my table, I saw that all 4 functions are still being run every 5 minutes. When I ran php artisan: schedule:run, the log showed only the 3 desired functions. But that's only when I run it manually, and it had no change on what was being run automatically.
I have seen stuff about cron, but I am confused if this is something I need to enter on the command line or if it might be some file I need to set up to get my scheduler to properly update?
This is what I am referring to that I saw on the Laravel documentation site:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Any advice or direction would be much appreciated:
I've been bitten by this more often than I care to admit. It is potentially a caching issues. Run the following:
php artisan cache:clear
php artisan queue:restart
The queue is the one that gets me every time.

Laravel 5.5 Job with delay fires instantly instead of waiting

In my application I am dispatching a job on work queue with delay time. But its work instantly not waiting for delay time. In my config and eve I am using driver as database.
In my database job table not insert any job till now.
My config:
'default' => env('QUEUE_DRIVER', 'database')
My controller code:
Log::info('Request Status Check with Queues Begins', __METHOD__);
MyGetInfo::dispatch($this->name,$this->password,$this->id,$trr->id)->onQueue('work')->delay(12);
return json_encode($data);
The value of QUEUE_DRIVER must be set to database in .env file.
make sure to run this afterwards:
php artisan config:clear
also run
php artisan queue:listen

Laravel Artisan - reload .env variables or restart framework

I'm trying to write a command as a quickstart to build a project. The command asks for input for database details and then changes the .env file. The problem is that the command needs to do some Database queries afterwards, but the .env variables are not reloaded.
My question would be, is there a way to reload or override .env variables runtime. And if not, is there a way to call another Artisan command freshly, so framework bootstraps again?
In my command I tried doing $this->call('build:project') in my actual command, but even in the second call the variables are not reloaded.
Is there a way to achieve this without making the user manually call multiple commands?
Thanks!
i had the same problem with reloaded .env variables, and i fixed it with this command line which allow you to clear the configuration :
php artisan config:clear
Hope that helped. Regards.
Laravel uses config files which take data from .env file. So, what you can do is to override configuration values at runtime:
config(['database.default' => 'mysql']);
Try to clear cache it helped me (couldn't ssh into the server)
Is there a {app route}/bootstrap/cache/config.php file on the production server? Delete it.
This helped me
As OP I'm trying to bootstrap a Laravel project build by running console command and asking for the database credentials in the middle of the process.
This is a tricky problem and nothing I read was able to fix it : reset config, cache, Dotenv reload, etc... It seems that once the console command / operation is initialized the initial database connection is kept all over until the end.
The working solution I found is to bypass, after database modification are done, this cached state by using native shell exec command and passing the php artisan command as parameter :
passthru('php artisan migrate');
So, the order will be :
php artisan project:build (or whatever is your console command)
prompt the user for database credentials
replace values in .env file (your search & replace algorythm)
run php artisan config:cache
passthru('php artisan migrate'); ro run your migrations
shell_exec would do the same but in silent mode while passthru will return the output generated by console.
https://www.php.net/manual/en/function.passthru.php
Done successfully on Laravel 8.52

Laravel artisan optimize not creating bootstrap/compiled

I used to have a bootstrap/compiled.php file. Then I accidentally deleted it, and because for some reason it was in .gitignore, I don't have another copy of it. How do I get it back?
I tried running compose dump-autoload and php artisan optimize, neither of these generated the file. Where does it come from? How do I produce it?
Laravel 4.1+ does not create bootstrap/compiled.php on development boxes anymore, only in 'production'. Actually Laravel checks if debug mode is on if it is, it will not generate the compiled.php.
But you can:
php artisan optimize --force
To force its creation.
Switch debug mode to false in app/config/app.php and run your command again.
'debug' => false,

Categories