How to change Laravel 5 sessions to redis - laravel

I now set a lot of values to the session using Session::put and Session::get. If I want to use Redis throughout the application, is it true that I just need to replace all Session:: with Redis:: to make it work?
By the way, I already installed the Redis package

All you have to do is just changing your .env file :
SESSION_DRIVER=redis
and use Session::get() etc.

You should change in connfig/session.php 'driver' => env('SESSION_DRIVER', 'file'), file to redis.

Related

how to change database configs in laravel?

My larave app have setup steps.
In the database configuration step, user inputs should be placed as database configuration, but i dont know how can i set custom configs for database.
I used this code, but it changes the configs temporarily and doesn't save them.
Config::set("database.connections.mysql", [
"host" => "...host...",
"database" => "...database...",
"username" => "...username...",
"password" => "...password..."
]);
Just try to change .env file or on config/database.php do your corrections

How to disable Redis in Laravel for dev version

I have a Laravel API that I need to test locally. How can I disable Redis cache on a local Laravel server? I can't disable it manually deleting all Redis::connection cases.
You can change "Default Cache Store" in config/cache.php file in your project.
By default you should have this 'default' => env('CACHE_DRIVER', 'file'),
You have a few solutions depending on what you have there:
if you already have changed default cache driver on that file, just change it to 'file' (not recommended!)
better would be change to default value 'default' => env('CACHE_DRIVER', 'file'), but add appropriate value in .env file CACHE_DRIVER=file

hide laravel application from wappalyzer extension

I am trying to hide laravel application from wappalyzer extension, already i changed my session name and clear cache but still wappalyzer can detect laravel application.
In the config/session.php, try changing:
'cookie' => 'laravel_session',
To something like:
'cookie' => 'app_name_session',
Laravel 8 - .env file just change your APP_NAME=Value
APP_NAME=Your Application Name
Ex:
APP_NAME=bismillah
Wappalyzer Extension - Setting - Clear cached detections
.env
Wappalyzer- Clear cached detections
Wappalyzer

Bypass Cache when in Dev Environment

Case scenario:
$dbResult = myEloquentClass::remember(60)->all();
My results are being cached, which works great for a production environment.
However, i am finding myself removing the remember method in my development environment since i don't want to cache my database results.
This results in a lot of unnecessary removal/additions of code.
Is there a way to bypass the cache globally for eloquent's remember when in development environment?
In laravel - 4 edit the app/config/local/cache.php file and set the driver to array.
<?php
return array(
'driver' => 'array',
);
For laravel 5 - edit the .env file and set the CACHE_DRIVER to array
CACHE_DRIVER=array
As posted by #bogdan,
I switch my development cache.php config file's driver to array, and works as advertised.

How do you set default engine for the Schema Builder?

How can you set a default engine when using migrations (Schema Builder)? I recently got place on a shared hosting and their default MySQL engine is MyISAM. Instead of having to rewrite all my migration files to include $table->engine = 'InnoDB' I'm wondering if you can set this as default.
Is it possible?
I don't think it is,the docs http://laravel.com/docs/schema#storage-engines. Can't find any other mentioning of db engine in the docs.
You would expect it to be possible in app/config/database.php
I manage to do it. I'm using Laravel 5.5. In the config/database.php:
'connections' => [
'mysql' => [
...
'engine' => env('DB_ENGINE', null)
],
As you may know this will fetch the DB_ENGINE var from en .env file.
So in that file I setted like this:
DB_ENGINE=MyISAM
It will work if you set the var to InnoDB also.

Resources