laravel 4: key not being generated with artisan - laravel

When running
php artisan key:generate
I can see the generated key in my shell, but the variable 'key' in app.php remains empty.
Running on localhost with windows-apache-php 5.4 - mysql.
Never had this problem before with laravel 4 beta version.

Had the same problem ...
Opened app.php
Remove the entry that says 'YourSecretKey!!!'
Ran 'php artisan key:generate'
Showed me a key in the console, but nothing in app.php!
Solution is ... unlike Laravel 3, don't delete the default YourSecretKey!!! in app.php, just run the command and it will work.
Hope this helps.
Bagwaa

You should not remove the original key, just go to your project directory and run
php artisan key:generate
it will work if you don't touch the previous key.

Have the same problem with L6 on Windows with xampp.
Remove the cached config php artisan config:clear
Regenerate key php artisan key:generate
Hope it helps.

The .env file needs to contain a line like this:
APP_KEY=
You don't have to specify a key, but you have to at least provide a .env file and also the above line.

first type any 32 character like 'hyhyhGGyhyhyhyhy23hyhy23hyhy23hy' this and then re execute the command in terminal/cmd.
Step 1:
go to app ---> Config --> app.php
step 2:
'key' => '10101010101010101010101010101010', type any 32 digit or character in that place.
step 3:
go to terminal / cmd
& type : "php artisan key:generate"
press enter
step 4:
see the key has been changed :)
[ It is because in Laravel 4 By using "php artisan key:generate" we simply can replace the default key any time. But if it is an empty space it can not be able to hold the place. ]
Enjoy coding :) \m/

The key generator will only update the APP_KEY in the .env file.
'key' => env('APP_KEY', 'YourSecretKey'),
config/app.php this is reading the APP_KEY from your .env file. The second parameter is a fallback.

Follow this simple steps:
Remove the cached config php artisan config:clear
Remove existing key or ensure that you have this line : APP_KEY= on your .env file.
Regenerate key php artisan key:generate

I was having the same issue. From my project directory I noticed I had the .env file, when I opened the project in atom (my code editor) I noticed that file appeared as .env.txt, I removed the .txt part and ran the command. It worked for me.

Related

Laravel 5.6 env('APP_BASE_URL') returns null

In staging and production environment, when I try to get my custom defined variable from .env file, it returns null. I have tried creating new Key for APP and cleared all sort of caches, but result is same.
APP_NAME="App - Staging"
APP_ENV=staging
APP_KEY=<HIDDEN_KEY>
APP_DEBUG=true
APP_LOG_LEVEL=none
APP_URL=https://staging.app.com
APP_BASE_URL="https://app-staging.app.com"
Clearing Cache
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan config:cache
But when using following in blade view gets nothing
env('APP_BASE_URL') returns null
It is because you have run php artisan config:cache. If you are using config:cache, your env() calls should only be made in your config files.
See here: https://laravel.com/docs/5.6/configuration#configuration-caching
This post solved my issue, I defined custom config in config/app.php
https://laracasts.com/discuss/channels/laravel/accessing-custom-environment-variable
/*
|-------------------------------------------------------------------------
| Custom config variables
|-----------
|
*/
'base_url' => env('APP_BASE_URL', 'http://localhost'),
Then in .env I definded:
APP_BASE_URL="https://app-staging.app.com"
Finally cleared the cache, worked.
In blade view
{{ config('app.base_url') }}
Yes it will return only null
If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null.
See the laravel documentation https://laravel.com/docs/5.6/configuration#configuration-caching

laravel 5.2 config constant does not work on server

i seperate my strings and put them in Constant directory in textConstant.php file , in my localhost everythings are okey but when i uploads my code on my server the string fade out and nothing show in my screen ,
here is my constant file :
return [
'title' => 'test',
'book' => 'book_test',
];
and here is my code that use constant :
<button>{{config('Constants.textConstant.book')}}</button>
please help me to solve my problem because my site cannot be usable, thanks alot :)
Try to run the following code over commandline if you have enabled the cache.
php artisan config:clear
php artisan config:cache.
In CMD;
Write first
php artisan config:clear
Then
php artisan config:cache
Hope this will work.

Class App\Http\Controllers\Auth\AuthController does not exist

i followed these , laravel virsion 5.4.16
https://www.youtube.com/watch?v=bqkt6eSsRZs&t=29s
You need to regenerate namespaces autoload
composer dump-autoload
"php artisan make:auth" produces all the authentication scaffolding required for the authentication process.
Type "php artisan make:auth" in your terminal right in the directory of your project. You will need to tidy up your install by deleting the "layouts folder" folder within the "resources folder", and also change the "#extends('layouts.app')" to "#extends('main')" in the login.blade.php and register.blade.php views within the "resources/views/auth" folder. Also you should then run "php artisan route:list" to see the names and locations of the auth routes.
I hope this helps

After upgrading laravel 5.1 to 5.2 \App::environment() always returning "production"

I upgraded laravel 5.1 to 5.2, everything looks good.
But when try to access the app environment not getting what expected.
When i dd($_ENV) this is what i get
"APP_ENV" => "vagrant"
"APP_DEBUG" => "true"
"DB_HOST" => "localhost"
But When dd(\App::environment());
"production"
P.S. even I checked in tinker: dd(env('APP_ENV')) gives me "vagrant"
but dd(\App::environment()) gives me "production".
Dont you think it is odd :(
This is wierd :(
Anyone face this problem ??
you missed a step in the upgrade process:
Configuration
Environment Value
Add an env configuration option to your app.php configuration file that looks like the following:
'env' => env('APP_ENV', 'production'),
P.S. You can check the value from the artisan command:
php artisan env
Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work
php artisan config:cache
php artisan config:clear
php artisan cache:clear

Laravel 4 - unserialize(): Error at offset 0 of 32 bytes

When I install Laravel 4, I receive this error:
ErrorException
unserialize(): Error at offset 0 of 32 bytes
C:\xampp\htdocs\blog\laravel\bootstrap\compiled.php
return unserialize($this->stripPadding($this->mcryptDecrypt($value, $iv)));
If I modify return like this:
return unserialize(base64_decode($this->stripPadding($this->mcryptDecrypt($value, $iv))));
Then the error goes away. But of course every time I run composer update this change will be undone.
What could be the reason of this problem?
I appreciate any help.
Update: This only happens when I use Auth::check().
Update 2: Now it only works with base64_decode() removed. It's like if the xampp installation has become self-aware. Jesus!
Refer to this issue: laravel/framework#1526
A change in the encryption mechanism is the cause. My solution was to empty out the sessions and views that were cached in the storage folder, then run php artisan key:generate and relaunch the server. I'm not sure which part of the process fixed the issue, but I haven't seen it since.
The command > php artisan cache:clear fixed the problem for me.
I did not have to restart the server
Can you post what you're doing that causes this error? You shouldn't be modifying the core - because as you said, updates will overwrite it.
You have to set a news Key, use the following command:
php artisan key:generate
After that test again to run the Laravel Application
php artisan serve

Resources