Laravel Runtimeexception error - php

With xampp I made a virtual host named leeromgeving.dev. But when I enter this in my bar its shows this.
It worked before, I don't know what is causing this. If I need to provide some code. Please inform me.
Thanks for the answers but unfortunately none of them worked.
This is what I get now after typing this in

Try Following Steps
-> delete .env file
-> copy .env.example .env
-> php artisan key:generate
-> remove env() in 'key' in config/app.php
or See https://laracasts.com/discuss/channels/laravel/the-only-supported-ciphers-are-aes-128-cbc-and-aes-256-cbc-with-the-correct-key-lengths

you have to insert the APP_KEY in your env file, use this command to generate a new Application key
php artisan key:generate

Related

Change laravel project name

I want to change my Laravel 8 project but I run into an issue when I use this command: php artisan app:name new_name
The error is:
There are no commands defined in the "app" namespace.
I went through some solutions proposed in Stack Overflow, Github and other forums, but nothing seems to solve the issue.
Thanks in advance for your help!
Run php artisan list to see all the commands available
There is none app:name
To change the name of your project edit your .env and modify APP_NAME
go to .env file
open .env file in any code editor
find at APP-NAME = "" in .env file
edit APP-NAME = "Your Project Name"
put your desired name in "" (double quotes)
save .env file
restart your server
I think it will be work.
Thanks
// go to .env file change your app name example below
APP_NAME=type your project name here
Got to .env file at the root of you project and update APP_NAME="Your app name"
Also php artisan app:name new_name doesn't exist. You can do php artisan list to see all available artisan commands.

Cant generate php artisan key

Ia m trying to set up Snipe IT on Windows server 2016 (VM) . I stack on part where i need to generate key.
When i execute php artisan key:generate i get following error.I checked ".env" file and I think everything is correct. I tried with composer install and update but same error acours...
Does anyone now how to fix this issue ?
Many thanks in advance
https://i.stack.imgur.com/vUmBk.png
Do you mean to generate application key?
'key' => env('APP_KEY', 'SomeRandomString') in file app.php
if you mean it then executes this command php artisan key:generate

Class 'Sentry\ClientBuilder' not found when trying to install Sentry

I am currently trying to add Sentry to my Laravel project but I got hit in this issue when I did
composer require sentry/sentry-laravel.
The error I got hit with is:
#php artisan package:discover --ansi
Error
Class 'Sentry\ClientBuilder' not found
at vendor/sentry/sentry-laravel/src/Sentry/Laravel/ServiceProvider.php:122
118| ],
119| $userConfig
120| );
121|
> 122| $clientBuilder = ClientBuilder::create($options);
123|
124| // Set the Laravel SDK identifier and version
125| $clientBuilder->setSdkIdentifier(Version::SDK_IDENTIFIER);
126| $clientBuilder->setSdkVersion(Version::SDK_VERSION);
• Database name seems incorrect: You're using the default database name `homestead`. This database does not exist.
Edit the `.env` file and use the correct database name in the `DB_DATABASE` key.
https://laravel.com/docs/master/database#configuration
My .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Laravel version: 7.5.2
I am running everything throught Homestead and my database does exist and the project is running but I cannot figure out why do I get this error.
Thank you in advance for your help!
use this composer require sentry/sentry-laravel:1.7.0
Since you’re using Laravel 7 the package will be auto-discovered in your
config/app.php.
#NinetyHH this is really weird, I think the database "tip" in unrelated, it tries to be smart and fails giving a confusing message :)
Can you add "sentry/sentry-laravel": "^1.7", to your composer.json manually and running composer update to see if that resolves the issue, to me it looks like the dependency was not correctly installed.
If that doesn't fix it, can you:
share your PHP version
share your composer.json (so I can try and see if I can replicate it locally)
share the full output of composer require sentry/sentry-laravel (so we can see what composer is doing)

Laravel 5.2 not working on php 7 on Windows 10

I have followed every direction but I cannot get Laravel 5.2 to work on php 7 on Windows 10. On the same server I have Laravel 4.2 (this is the app I want to upgrade) working with no issues whatsoever. None of the answers on similar questions seem to work.
The error I get is:
No supported encrypter found. The cipher and / or key length are invalid.
If I chage the cipher method to MCRYPT_RIJNDAEL_128 the error becomes:
mcrypt_encrypt(): Key of size 0 not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported
I have tried
php artisan key:generate
php artisan config:clear
php artisan clear-compiled
php artisan config:clear
adding app key to /config/app.php, deleting the .env file, adding the key to both .env and app.php and still does not work.
Currently, my .env file looks like this.
and my app.php file looks like this.
How do I solve this problem? Currently only the home page is working. The login and register pages fail with the errors specified above.
Laravel was installed like this: create-project --prefer-dist laravel/laravel appdir
Don't worry this is a common problem that is easy to miss.
In your app.php file you are trying to find an env key of somestring (in this case the actual value you want to return) and not the key in which you set the value in the env file.
Setting the key in your app.php file as the following:
'key' => env('APP_KEY')
Should correctly look for the APP_KEY in your env file and set the corresponding value!

Laravel 5.2 not reading env file

After upgrading to Laravel 5.2, none of my .env file values are being read. I followed the upgrade instructions; none of my config files were changed except auth.php. They were all working fine in previous version, 5.1.19
.env contains values such as
DB_DATABASE=mydb
DB_USERNAME=myuser
config/database.php contains
'mysql' => [
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
]
I get this error:
PDOException: SQLSTATE[HY000] [1045] Access denied for user 'forge'#'localhost' (using password: NO)
Clearly not pulling in my env config. This is affecting every single one of my config files, including third party such as bugsnag.
I also tried
php artisan config:clear
php artisan cache:clear
Update
Trying php artisan tinker
>>> env('DB_DATABASE')
=> null
>>> getenv('DB_DATABASE')
=> false
>>> config('database.connections.mysql.database')
=> "forge"
>>> dd($_ENV)
[]
I have tried installing a fresh copy of Laravel 5.2. I basically only copied in my app folder; no additional composer packages are included. Still having the same issue. I have other Laravel 5.2 projects on the same server that are working fine.
If any of your .env variables contains white space, make sure you wrap them in double-quotes. For example:
SITE_NAME="My website"
Don't forget to clear your cache before testing:
php artisan config:cache
php artisan config:clear
From the official Laravel 5.2 Upgrade Notes:
If you are using the config:cache command during deployment, you
must make sure that you are only calling the env function from within
your configuration files, and not from anywhere else in your
application.
If you are calling env from within your application, it is strongly
recommended you add proper configuration values to your configuration
files and call env from that location instead, allowing you to convert
your env calls to config calls.
Reference: https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0
For me it has worked this in this order:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
And I've tried all the rests without luck.
Wow. Good grief. It's because I had an env value with a space in it, not surrounded by quotes
This
SITE_NAME=My website
Changed to this
SITE_NAME="My website"
Fixed it. I think this had to do with Laravel 5.2 now upgrading vlucas/phpdotenv from 1.1.1 to 2.1.0
I had a similar issue in my config/services.php and I solved using config clear and optimize commands:
php artisan config:clear
php artisan optimize
You can solve the problem by the following recommendation
Recommendation 1:
You have to use the .env file through configuration files, that means you are requrested to read the .env file from configuration files (such as /config/app.php or /config/database.php), then you can use the configuration files from any location of your project.
Recommendation 2: Set your env value within double quotation
GOOGLE_CLIENT_ID="887557629-9h6n4ne.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="YT2ev2SpJt_Pa3dit60iFJ"
GOOGLE_MAP="AIzaSyCK6RWwql0DucT7Sl43w9ma-k8qU"
Recommendation 3: Maintain the following command sequence after changing any configuration or env value.
composer dump-autoload
composer dump-autoload -o
php artisan clear-compiled
php artisan optimize
php artisan route:clear
php artisan view:clear
php artisan cache:clear
php artisan config:cache
php artisan config:clear
Recommendation 4: When the syntax1 is not working then you can try another syntax2
$val1 = env('VARIABLE_NAME'); // syntax1
$val2 = getenv('VARIABLE_NAME'); // syntax2
echo 'systax1 value is:'.$val1.' & systax2 value is:'.$val2;
Recommendation 5: When your number of users is high/more then you have to increase the related memory size in the server configuration.
Recommendation 6: Set a default probable value when you are reading .env variable.
$googleClinetId=env("GOOGLE_CLIENT_ID","889159-9h6n95f1e.apps.googleusercontent.com");
$googleSecretId=env("GOOGLE_CLIENT_ID","YT2evBCt_Pa3dit60iFJ");
$googleMap=env("GOOGLE_MAP","AIzaSyCK6RUl0T7Sl43w9ma-k8qU");
I missed this in the upgrade instructions:
Add an env configuration option to your app.php configuration file that looks like the following:
'env' => env('APP_ENV', 'production')
Adding this line got the local .env file to be read in correctly.
I had the same issue on local environment, I resolved by
php artisan config:clear
php artisan config:cache
and then cancelling php artisan serve command, and restart again.
Same thing happens when :port is in your local .env
again the double quotes does the trick
APP_URL="http://localhost:8000"
and then
php artisan config:clear
Also additional to what #andrewtweber suggested make sure that you don't have spaces between the KEY= and the value unless it is between quotes
.env file e.g.:
...
SITE_NAME= My website
MAIL_PORT= 587
MAIL_FROM_NAME= websitename
...
to:
...
SITE_NAME="My website"
MAIL_PORT=587
MAIL_FROM_NAME=websitename
...
I solved this problem generating a new key using the command: php artisan key:generate
if you did call config:cache during local development, you can undo this by deleting the bootstrap/cache/config.php file. and this is work for me.
In my case laravel 5.7 env('APP_URL') not work but config('app.url') works. If I add new variable to env and to config - it not works - but after php artisan config:cache it start works.
if you did call config:cache during local development, you can undo this by deleting the bootstrap/cache/config.php file. and this is work for me.
#Payal Pandav has given the comment above.
I want to tell a simple workaround. Just edit the config.php file in the bootstrap/cache/ folder. And change the credentials. This worked for me. Please don't delete this file since this may contain other crucial data in the production environment.
I experienced this. Reason was that apache(user www-data) could not read .env due to file permissions.
So i changed the file permissions to ensure that the server (apache) had read permissions to the file. Just that and boom, it was all working now!
Update:How to do this varies, depending on who owns the .env file, but assuming it belongs to the Apache www-data group, you can do this:
sudo chmod g+r .env
Modify it depending on your permission structure.
In my case, I needed to restart my Supervisord jobs (i.e. my queue workers). After doing so, a new environment variable I had added to my .env file was successfully pulled into my application.
Remember, queue workers, are long-lived processes and store the booted application state in memory. As a result, they will not notice changes in your code base after they have been started. So, during your deployment process, be sure to restart your queue workers. In addition, remember that any static state created or modified by your application will not be automatically reset between jobs.
Source: Official Laravel Docs - Queues
I know this is super old, but today I discovered another reason why my .env was not loaded:
I had a (commited) .env.local
I recently switched APP_ENV from dev to local
With L8 (and maybe before), what happens is that it tries to find .env.<APP_ENV> and if it finds it, uses it.
Fun fact: in my case, .env.local was a blue-print file with non-sensitive information and not meant to be directly used, but that's what happened.
Removing the .env.local led to Laravel looking for .env instead.
In my case I was using VSCODE and it turned out my .env file was auto-dectected by the IDE as a shell script file and not an Ini which was causing me the issue. It's a rare occurrence, but I hope it will save someone time.
For Laravel coder. We can use config() to solve this problem
in file "config/app.php":
'same_url' => env('SAME_URL', 'http://localhost'),
in your code base:
$sameURL = config('app.same_url').'/orders/';
If you've come here because you have multiple .env.* files and php artisan config:cache resulted in incorrect settings, it's because it (tried to) read the .env file and not the one specific to your environment. Try this instead (where CODE corresponds to .env.CODE):
APP_ENV=CODE php artisan config:cache
I made the mistake by doing dd/die/dump in the index.php file. This causes the system to not regenerate the configs.
Just do dump in view files will do. The changes to .env file update instantly.
I had some problems with this.
It seemed to be a file permission issue somewhere in the app - not the .env-file.
I had to
- stop my docker
- use chown to set owning-rights to my own user for the whole project
- start docker again
This time it worked.
If you're using sail environment right after you change your environment variable just restart a server, otherwise it's going to show the old value.
In my case (Laravel 7.x) it happen because I had set environmental variable on server. To be precise in Docker container.
And because environments variables are higher priority than .env file, nothing changes during .env file edit.
Check if you set the env variable on the server:
echo $VAR_NAME
Tried almost all of the above. Ended up doing
chmod 666 .env
which worked. This problem seems to keep cropping up on the app I inherited however, this most recent time was after adding a .env.testing. Running Laravel 5.8

Categories