I'm have an issue in accessing the env variables from env file in Laravel.
The application is already hosted to one of shared hosting sites.
When I printed the APP_KEY variable, it returns empty.
I tried to check if the env file exists by using file_exists function inside the index.php file in the public directory and it returns true yet I cannot access the env variables.
Thus, resulting to error in cipher because of empty appkey.
This happened after this code block in the index.php file in the public directory:
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
When I print the $response->send(), it showed the cipher error.
I did the same thing in my local and it displayed the appkey value with no cipher error.
The files I used in the shared hosting site are the same files from my local. This is the first time I host the Laravel application. Maybe there are some things I missed?
Do you have any idea why this happening? Thanks.
php artisan key:generate?envfile