I am using Laravel 5.7. My application is working fine last night. but suddenly this error appears. I did not change any file. Now I am searching for a solution but I did not find any. I am new on laravel I am not familiar with core files of Laravel.
please check the error in the attached image.
here is .env session portion
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
And this is env file code
I dont have any file session.php file in config
Going of the conversation in the comments, the issue is that you don't have a session.php inside your config directory. The reason this is an issue is because Laravel will use that config file to get the name of the session driver and, like all config values, if it isn't present it will just return null.
Adding the default session config file to that directory should solve your issue.
Related
I have my server key in .env on production but sometimes notification stops working as server key not accessable .
But when I run the command php artisan config:cache then it again starts working .
Do not access the variable of .env directly in controller or inside any file. First you have to access that variable in any config file.
Like below:
For e:g; inside config/app.php define your server key
'server_key' => env('server_key')
after defining above key in config/app.php you have to access it inside any file as below:
config('app.server_key')
By doing this you will permanantly resolve your issue.
In my Laravel-8, I deleted .env when I'm about to deploy to production.
In the .env, I have:
APP_KEY=base64:JMKPPddG+sPK/ufZKNGwGTStKbMLO2Vnv/4i2fA3j1c=
and config/app:
'key' => env('APP_KEY'),
Everything was working fine until when I deleted .env
When I run the application, I got this error:
production.ERROR: No application encryption key has been specified in Laravel
I don't want to use .env
How do I get this resolved?
Thanks
first run this command to cache configurations:
php artisan config:cache
then u can remove .env
note: calling env() helper from your code will always return null because .env values can be accessed only from config files.
blocking access to .env file in the server is a better solution though.
Today I tried uploading my first website,but i'm getting an error.On the local server it works fine but when I uploaded it to the live server,i'm getting an error that is saying "Whoops, looks like something went wrong".To be more specific it's showing twice on the same page.Check the image bellow.
Steps followed while uploading project to live server:
Zipped the file
Created a new folder at the root directory.
Unzipped the file in the new folder.
Moved all the files from public folder to /public_html/
Edited the locations on the index.php file.
Note: Other than index.php I haven't altered any other file.
I followed a lesson on youtube and with these steps, his project worked but mine is throwing an error.
I have also noticed that after unzipping the folder in the cpanel the .env file is missing.Could this be the issue?
Make the .env file is there .
Then don't forget to generate the application key
php artisan key:generate
There are some times that the .env file isn't being read by the server. You may try to edit the .env file and supply the necessary credentials according to your server such as the following:
APP_URL= *
APP_KEY= *
DB_CONNECTION=mysql
DB_HOST= *
DB_PORT=3306
DB_DATABASE= *
DB_USERNAME= *
DB_PASSWORD= *
The lines with the asterisks are the ones you typically need to fill up. The APP_KEY can be set by using the php artisan key:generate command in your local workspace, then copy the value to your live server.
If the .env can't be read and it still shows an error, try to edit the config/app.php file and change 'key' => env('APP_KEY'), into 'key' => yourgeneratedkey,. Try to also change the values in your config/database.php file into the same one as your .env file
Follow the installation guide https://laravel.com/docs/5.6
Check the server requirements(check if all the required extensions are installed).
Check if all the files are there.
Check Configurations
check config.php file
check directory permissions.
generate application key (php artisan key:generate)
Check if .env exists or not
thanks to all of you who replied.I found the solution.It turns out the cause for the error was a simple spelling mistake in my .env file.
This is caused by missing ".env" file, copy the content of ".env.example" file and create a new ".env" file in the same directory as your "example.env" file.
then run: php artisan key:generate
I'm trying to install Backpack base using this comand: php artisan backpack:base:install
After few seconds I receive this error:
I tried to install backpack/generators manually but the problem is still the same.
Backpack can only be installed on an working Laravel instance. And it looks like your Laravel installation can't connect to the database. This usually happens:
A) when you haven't properly setup the .env file with your DB credentials; review your .env file; keep in mind you might also need to specify a db socket; by default homestead apps work with this db configuration:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=homestead
DB_PASSWORD=secret
B) when you're running the command outside your homestead box; SSH into homestead first, then run the installation commands;
Hope it helps.
I tried all of your ideas but it still didn't work still, thanks for the suggestions. Anyways I just created a new project in laravel 5.5 and it did actually worked.
Anyone familiar with this error i'm getting?
Please help thanks.
If you are using Laravel 5.3 do the following:
From the upgrade guides: The AuthorizesResources Trait
The AuthorizesResources trait has been merged with the AuthorizesRequests trait. You should remove the AuthorizesResources trait from your app/Http/Controllers/Controller.php file.
Seems like the problem is with your version of laravel/framework.. Running composer update should pull in the latest version (which is 5.2.39). If that doesn't work for you, then I'm not sure what else you can do. Perhaps try composer self-update before you do it.
If you run composer info laravel/framework the 4th line should show you the latest version from packagist, which is: 5.2.39.
Edit: You could try and clear your package cache: composer clearcache
Does Laravel connect to database? I had this error and it was caused by a wrong database configuration in .env file.
Try these settings in .env file:
1. Open .env file in your project's folder. Don't touch the .env.example file found in the same location as it's an example of .env default configuration. If something goes wrong with your .env file, you can copy and paste the configuration from the .env.example file to .env.
2. Change the following 4 lines to your own configuration:
DB_HOST=localhost
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=
DB_DATABASE It's the name of your database. Should be 'forge' by default or check your phpMyAdmin to determine which database you need to use. You can create a new database if you're an administrator of phpMyAdmin ('root' user).
DB_USERNAME This is your username when you log in to phpMyAdmin. Should be 'forge' by default.
DB_PASSWORD Your phpMyAdmin should not be protected with password by default. The password is set later manually. In case you'll set the password, add it to DB_PASSWORD line after you do so.
3. Save the modified .env file and restart the Apache server.
Try to access your webpage again. This worked for me. I hope it's gonna work for you, too.
P.S. If it doesn't work, check if the .env configuration is right for you. Or use php artisan config:clear to clear cache.