I've install Yii2 framework using composer but get this error in my browser (on localhost):
Invalid Configuration – yii\base\InvalidConfigException
yii\web\Request::cookieValidationKey must be configured with a secret key.
How can I solve this problem?
There is this problem with basic app now https://github.com/yiisoft/yii2-app-basic/issues/69 where composer install doesn't generate this key.
You need to add this key manually.
Go to /config/web.php.
Edit the line 'cookieValidationKey' => '', to include random string (you can use anything like 'cookieValidationKey' => 'jfsbkjsbfdskjgfdskjbgfsdhjgfajds',
You need to set cookieValidationKey in the config file to a random string. The config file is located under yii/your-projectfolder/config/main-local.php if you are using Yii 2.0 Advanced Template
You need to set cookieValidationKey value in project/config/web.php at line 12.
change at:
'cookieValidationKey' => '',
replace with:
'cookieValidationKey' => 'setyourkey',
That should address the issue.
Try this
open Frontend/ config / main.php
'components' => [
'request' => [
'enableCookieValidation' => true,
'enableCsrfValidation' => true,
// 'cookieValidationKey' => 'xxxxxxx', // if u dont hv key just comment it
],
],
if you have a web.php
'components' => [
'request' => [
'enableCookieValidation' => true,
'cookieValidationKey' => 'your-validation-key',
],
Related
I am using Laravel Debugbar https://github.com/barryvdh/laravel-debugbar with Laravel 7.x according to documentation it should be show this
but my debugbar missing few tabs Route, Auth, Session, Gate etc. please see below
Please Help i can get above shown tabs
Regards,
Thanks in advance
Publish the config debugbar.php in /config
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
you can customize tabs in the config/debugbar.php :
...
'collectors' => [
'phpinfo' => true, // Php version
'messages' => true, // Messages
'time' => true, // Time Datalogger
'memory' => true, // Memory usage
'exceptions' => true, // Exception displayer
'log' => true, // Logs from Monolog (merged in messages if enabled)
'db' => true, // Show database (PDO) queries and bindings
'views' => true, // Views with their data
'route' => true, // Current route information
'auth' => false, // Display Laravel authentication status
'gate' => true, // Display Laravel Gate checks
'session' => true, // Display session data
'symfony_request' => true, // Only one can be enabled..
'mail' => true, // Catch mail messages
'laravel' => false, // Laravel version and environment
'events' => false, // All events fired
'default_request' => false, // Regular or special Symfony request logger
'logs' => false, // Add the latest log messages
'files' => false, // Show the included files
'config' => false, // Display config settings
'cache' => false, // Display cache events
'models' => true, // Display models
],
....
don't forget to do
php artisan config:clear
if you use config cache
I tried composer dump-autoload and php artisan config:clear and it resolved my problem thanks to all to help me
I am using Laravel 8.x and the Debugbar was not showing the Auth tab. This seems to be the default setting. I published it using the instructions above, and edited the config/debugbar.php file setting 'auth' to true. What I missed, since I am new to PHP/Laravel, is that I should have edited the config/debugbar.php and not the vendor/barryvdh/config/debugbar.php. Once I edited the correct file, the tab was displayed. Thanks to all who contributed.
How do I tell the Laravel filesystem layer to use the s3 metadata on an EC2 instance? I don't want to provide hardcoded keys and secrets for my s3 buckets. I'm unclear on what the configuration should look like. When I exclude the key and secret from the filesystem configuration I get the following error
ErrorException
Undefined index: key
The fix is to leave empty placeholder values in place for key and secret. eg, in config/filesystems.php
return [
'cloud' => 's3',
'disks' => [
's3' => [
'driver' => 's3',
'key' => '',
'secret' => '',
'region' => env('S3_REGION'),
'bucket' => env('S3_BUCKET'),
],
],
];
The correct way to provide your credentials is by using the .env file.
In your .env file, add something like that:
EC2_SECRET=your_ec2_secret
EC3_KEY=your_ec2_key
and in the `` config file, use something like that:
'ec2' => [
...
'key' => env('EC2_SECRET'),
'secret' => env('EC3_KEY'),
],
You should now be able to use the service without having the credentials stored in the repository.
Is it possible to use two or more caching storage in yii2 framework? I already setup a Memcache for my web app but I wanted also to use a FileCache since I will be dealing with a large chunk of data.
hope someone can help. Thanks!
You can set any cache. Just set it at config file.
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'memCache' => [
'class' => 'MEMCACHE CLASS HERE',
],
.... ANY cache you want ...
]
You can register multiple cache application components. The component named cache is used by default by many cache-dependent classes (e.g. yii\web\UrlManager).
Official link
'components' => [
'cache' => [
'class' => 'yii\caching\MemCache',
],
'fileCache' => [
'class' => 'yii\caching\FileCache',
]
]
I am uisn glravel 5.1 and setting up mail service with Mailgun. I've just found that my services file contains lines like the following:
'mailgun' => [
'domain' => env('<domain>'),
'secret' => env('<key>'),
],
Now for some reason, these values get ignored as-is. However, if I remove the env() method from the above, it works. So now I have this:
'mailgun' => [
'domain' => '<domain>',
'secret' => '<key>',
],
Can anyone explain why this is?
Because by
env('foo');
You are asking for the content of the "foo" constant defined in the .env file. Do you have a constant in your .env file named 'foo'?
We configured like /var/www/app1 and /var/www/app2 , Both are logging in single session. How can I make this different session.
I tried with following solution from yii2 wiki. But it doesn't workout here.
'identityCookie' => [
'name' => '_backendUser', // unique for backend
'path'=>'/advanced/backend/web' // correct path for the backend app.
]
Please give solution for this issue.
Use a different session $name for each application. This can be set in your config as:
'components' => [
'session' => [
'class' => '\yii\web\Session',
'name' => 'mycustomname',