It is written in Laravel 5 documentation that php artisan config:cache stores all the app configuration into one single file which makes the application load faster.
I want to know two things:
The first thing is, how to force Laravel to stop caching my app configurations? For example, I want Laravel to read the name of my database and the password from the .env file or from the database.php configuration file, not from the cached data.
The second thing is, where does Laravel store this cached configuration file, so that I can delete it when needed? I know there is an Artisan command for that, which is php artisan config:clear, but I want to know where the file stored.
You can't stop the caching of config files since it doesn't happen automatically. The only thing you need to do, is not call config:cache.
The file itself can be found in bootstrap/cache/config.php.
Note that the location of the compiled config file has changed recently. Yours might also be in vendor/config.php or storage/framework/config.php. With a fresh install or if you run composer update the file should be in bootstrap/cache though.
As per the post here: https://github.com/laravel/framework/issues/2501
"Change cache driver to array for the local environment."
For me this involves adding CACHE_DRIVER=array to my .env file. This is then picked up by my config/cache.php file which includes the line:
'default' => env('CACHE_DRIVER', 'file'),
Obviously you could change it directly in the config/cache.php but I'd prefer to use the .env file so I can disable it for development sites and enable for production.
Related
If I do not run php artisan optimize and I go to a new route in the browser I get Page not found
Everytime you push a new version of your project to production it is recommended to run php artisan route:cache.
On dev environment it is recommended to have no cache and ensure that by running php artisan route:clear.
When you do
php artisan route:cache
A file like bootstrap\cache\routes-v7.php gets created holding all your routes from routes\*.php which are contained in Route methods that weight some calculation cost on your server each time you send a request to figure what to do for the current route.
Quoting from bootstrap\cache\routes-v7.php comments:
This allows us to instantaneously load the entire route map into the router.
Important:
This cache file doesn't get auto updates and doesn't exist in a fresh project.
This cache takes precedence over routes\*.php files.
The bootstrap\cache folder is ignored by default by git.
Here is an extensive great article for more details https://voltagead.com/laravel-route-caching-for-improved-performance/
Note that the optimize command was removed from the framework then added back.
I implemented my website on a shared hosting environment. Works perfect!
But now I changed functionality and want to use 'queues'. In my earlier instance the environment variable 'queue_driver' contained the default value 'sync', and now I changed that to 'database' in the environment file.
Question is now: how to activate this new setting?
I already tried to clear cache and config, but it does not change anything?
Can I enforce refreshment?
Use php artisan config:clear to clear the cached config files.
Maybe also follow up with composer dumpautoload
I update my .env file using a function in my controller.
After I save the settings I need to update, I call Artisan::call('config:cache') to clear the cache of my site's configuration.
Everything works fine on localhost, but when I try to clear config cache on production, it doesn't work. (No warnings or errors.)
I even tried with --no-interaction option attached to this CLI command.
Did anyone have this problem and know what causes it?
check into the PHP security settings and make sure you can run these exec,passthru,shell_exec functions in your server.
When I work with my local version of project then every action taken on website needs around 10 seconds long response. It's so frustraiting. And it hapens only on my PC. How can I prevent this action?? Downloading project from VCS to new folder helps for short time. I have Windows 10, Laravel 5.4, PHP 7.0.15. Commands
php artisan cache:clear
and
php artisan optimize
are not helping. Please, can anyone help?
Do you use xdebug? It can slow down application.
Also check your laravel debug option in .env file, it should be:
APP_DEBUG=false
That was laravel.log. I deleted it and everything seems to be ok. The file had 56MB of logs. Now i have to find out how to stop logging or create new log file every 2MB.
I recently upgraded my application from laravel 5.1 to 5.2 version. Also I am trying to store session in Database which is currently stored in file.
I have changed .env file to include SESSION_DRIVER=database. Also I have changed session.config file to include 'driver' => env('SESSION_DRIVER', 'database') and generated required session table.
But when I tried to login to the application I am getting TokenMismatchException in VerifyCsrfToken.php line 67: If I change SESSION_DRIVER=file then application is working as expected.
But this was not the case in Laravel 5.1 version.
What is changed in Laravel 5.2 version and what steps are required to store user session in database?
I had to deal with this issue myself as well. So the initial steps are as you had already mentioned in your question.
On fresh install of laravel and verify that everything works, change the SESSION_DRIVER=file to SESSION_DRIVER=database
Run the following commands IN ORDER in your console within the directory of your app:
php artisan session:table
composer dump-autoload
php artisan migrate
(This step might be different from what you did) In your config\session.php file search for:
'driver' => env('SESSION_DRIVER', 'file'),
and change it to the following
'driver' => env('SESSION_DRIVER', 'app.database'),
Within the same config\session.php file change the encrypt configuration to true
Set your connection and table name settings appropriately
'connection' => 'database_name_here',
'table' => 'sessions', //here you can change but sessions is recommended until you get more comfortable with how it all works
Attempt to login to your application and check your database to see if it all works.
If more help is needed you can also check a few resources that have helped me solve the issue. Keep in mind these resources are of people having similar issues but maybe your problem is similar to theirs. Only way to find out is to investigate. Hope this helps! =) :
https://laracasts.com/discuss/channels/laravel/how-to-store-users-id-in-session-table-laravel-5
https://laravel.com/docs/5.2/session
(Video tutorial on Laravel Sessions, VERY good place to help you get to where you need to be!)
https://www.youtube.com/watch?v=-FMecyZs5Cg
look it's ok to go with it manual but why don't u use the php artisan make:auth
it creates every thing u need for authentication and also helps u keeping the session instead of doing it manual ?