Yii2 Class yii\authclient\clients\GoogleOAuth does not exist - php

I use dektrium/yii2-user (on one project) and yiisoft/yii2-authclient (on another one) to login via Google account.
Some time ago it was everything ok, but i guess after last composer update something was changed and now i get an error: "Class yii\authclient\clients\GoogleOAuth does not exist" when try to open login page.
Does anybody has the same issue or know what's wrong?
Thank you

yii2-authclient has been modified in the latest version which is not backward compatible.
Read about the upgrade process here.
Two solutions:
Modify composer.json to fetch 2.0.6 version (replace * with 2.0.6) - no other changes are needed but no more updates for this extension.
Upgrade your code following the guide in the link above so you can be up-to-date.

In the config file
Replace from
'google' => [
'class' => 'yii\authclient\clients\GoogleOAuth',
..
],
Replace to
'google' => [
'class' => 'yii\authclient\clients\Google',
...
],

Use yii\authclient\clients\Google instead of yii\authclient\clients\GoogleOAuth in your config file.

Related

Laravel - Nexmo not picking up credentials in .ENV file

I recently added laravel/nexmo-notification-channel to my laravel project which also installed Nexmo/nexmo-laravel.
After installing, I published vendor files so that I get config/nexmo.php and in there I noted that it looks in the .env file for NEXMO_KEY and NEXMO_SECRET.
So I went ahead and created these within my .env file
NEXMO_KEY=[my_key]
NEXMO_SECRET=[my secret]
NEXMO_SIGNATURE_SECRET=[my signature secret]
After this, I added Nexmo to my service providers in app.php:
'providers' => [
...,
Nexmo\Laravel\NexmoServiceProvider::class
]
and also added the following in config/services.php:
'nexmo' => [
'key' => env('NEXMO_KEY', ''),
'secret' => env('NEXMO_SECRET', ''),
'sms_from' => '[my number]'
],
But I still get the following error when thrying to send an SMS using the use Illuminate\Notifications\Messages\NexmoMessage; class:
"message": "Provide either nexmo.api_secret or nexmo.signature_secret",
I can use these same credentials to send an SMS from CLI, so why can't I send it from laravel?
There have been a couple of workarounds for this that are valid, but at first glance it looks like the Nexmo package does the work to bring in the ENV secrets into Laravel's config. Because of caching problems, you should never call env() within Laravel, instead you should be using config() - so in this case, config(nexmo.api_secret).
My main point here though is that I can't look into the "correct" solution for you because the package is abandoned. Nexmo is no longer Nexmo, it's Vonage, and Laravel core team have subsequently updated the notification-channel package.
For supported use to integrate Vonage services (SMS), please use the following package:
https://github.com/laravel/vonage-notification-channel
I'm not sure exactly why, but, Vonage/Nexmo doesn't pick details from the .ENV.
Instead, use a global constant to fetch the secrets:
Create a global.php file in the config folder, and add your secrets from the env like this:
<?php
return [
// Other constants values
'SMS_API_KEY' => env('SMS_API_KEY', ''),
'SMS_API_SECRET' => env('SMS_API_SECRET', ''),
]
?>
Then, you can use the constants in your controller as usual:
'key' => config('global.SMS_API_KEY'),
'secret' => config('global.SMS_API_SECRET')
then: recache, php artisan config:cache

Yii2 Class dektrium\user\Module does not exist

I have designed Yii2 powered blog by creating models, views and controllers but when I integrate user registration as explained in this tutorial https://code.tutsplus.com/tutorials/how-to-program-with-yii2-integrating-user-registration--cms-22974 I get:
Class dektrium\user\Module does not exist
I fail to solve this error anyone who can direct me, please.
I think you need to include the required module via composer:
"dektrium/yii2-user": "*"
Then run the "composer update" command in your console.
Mabe you need to add to config:
'user' => [
'class' => 'dektrium\user\Module',
'admins' => ['MegaAdmin'],
],
If you have it in common/config/main.php try to replace to backend/config/main.php

Laravel Class 'Intervention\Image\ImageServiceProvider' not found

this question is asked many times and I did all the introductions I could found but I still get this error message.
I updated my config/app.php (
providers:
Intervention\Image\ImageServiceProvider::class,
aliases:
'Image' => Intervention\Image\Facades\Image::class,
and the composer.json
"intervention/image": "dev-master",
After this I did a composer update but my error message is still the same.. I'm using laravel 5
I did what the link says:
http://image.intervention.io/getting_started/installation
and yeah.. now I'm stuck
Another thing I dont understand is why they say I should write:
'Intervention\Image\ImageServiceProvider'
in the provider array. Why the ' '? All the other elements in my provider array are written like this:
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
so I removed the ' ' and addet ::class
the same with the aliases
I dont know if thats okay but maybe someone of you could help me
thanks for help
The ::class operator gives the fully qualified class name and was introduced in PHP 5.5 as you can see here. It's perfectly ok to use it if you have PHP >= 5.5.
I would suggest to check in the vendor directory if the package exists. I use "intervention/image": "^2.3" and everything's working great on L5.1

Swift_Message not found error after swiftmailer installed in Yii2

I'm setting up a mailer in a project using Yii2. Swiftmailer seemed to be the best solution for this framework so I simply followed the docs.
In composer.json
"yiisoft/yii2-swiftmailer": "*"
Followed by:
composer install
In my config I have: (Yes, I just want it to save a file for now.)
'components' => [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => true,
],
Then I placed this into a controller:
\Yii::$app->mailer->compose()
->setFrom('from#domain.com')
->setTo('to#domain.com')
->setSubject('Message subject')
->setTextBody('Plain text content')
->setHtmlBody('<b>HTML content</b>')
->send();
My error is:
PHP FATAL - Class 'Swift_Message' not found
I believe, after some research this has to do with the autoloader / lazy loading but the information I can find is spotty. Most of it states that if using composer to install resolves the issue, and all of my troubleshooting has left me chasing my tail.
Here's my stacktrace. Thank you for your help.
Additional:
composer-asset-plugin - IS INSTALLED
vendor/composer/autoload_files.php DOES contain the line:
$vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
I would love just close this embarrassment, but in case someone makes the same assumption as myself, i'd like to help.
Does you entry script contains 'vendor/autoload.php' require? Does it
point to the correct file? Try to manually put die('swiftmailer') at
'vendor/swiftmailer/swiftmailer/lib/swift_required.php' - it should
appear at any application run.
via (klimov-paul / yiisoft)
die('swiftmailer'); had no effect.
vendor/autoload.php is not required.
I had assumed that the other extensions already installed in the vendor folder were in use. I came to find that previous developers were not utilizing anything there and require(__DIR__ . "/../vendor/autoload.php"); was not in the execution path.

Configure Cakephp 2.6.0 with Redis Engine

I am trying to configure cakephp ver 2.6.0 to use redis engine by default. but somehow i am not able to make it work. any help will be highly appreciated.
Things Which i have tried so far..
Configured app/config folder 2 files , core.php and bootstrap.php. , according to the guidelines provided here in this blog configure cake with redis and this blog too Another cake-redis config setup
but i keep on getting errors like.
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine session is not properly configured.' in C:\wamp\www\project\cakephp\cakephp_2.6.0\lib\Cake\Cache\Cache.php on line 181
CacheException: Cache engine session is not properly configured. in C:\wamp\www\project\cakephp\cakephp_2.6.0\lib\Cake\Cache\Cache.php on line 181
Any help will be highly appreciated.
I was having the same exact issue today while trying to setup CakePHP to use Redis as the cache engine.
Coincidentally, I also read the same setup instructions from the two blogs you linked to.
The reason was that I had copied pasted the Configure::write(...) code block from the Another cake-redis config setup blog post as it is and pasted it into the file without first commenting out the Configure::write(...) code block that was already in the core.php file.
I'm assuming that you have already successfully setup Redis on Windows and have installed the PHPRedis extension without any issues.
I am using the instructions from Another cake-redis config setup here.
In your app/Config/core.php file, comment out the following block: (this was starting at line 218 in my core.php)
Configure::write('Session', array(
'defaults' => 'php'
));
Instead, you can put this in: (You can change the values to suit your particular needs)
Configure::write('Session', array(
'defaults' => 'cache',
'timeout' => 100,
'start' => true,
'checkAgent' => false,
'handler' => array(
'config' => 'session'
)
));
After this, change the value of $engine to 'Redis', so it becomes:
$engine = 'Redis';
And then, put this code in, I put this in at the very end of the file: (Again, your values can be different depending on what your setup is)
Cache::config ('session', array (
'Engine' => $engine,
'Prefix' => $prefix . 'cake_session_',
'Duration' => $duration
));
And that's it. You're done! No need to change anything else.
To make sure that Redis is working properly with CakePHP, I ran the RedisEngine Test Suite that comes with CakePHP. You need to have PHPUnit installed for this to work.
It can be accessed via http://your-cakephp-project/test.php
Click on 'Tests' under Core and then click on 'Cache/Engine/RedisEngine'
If everything is working successfully, you should see all the tests pass.
Alternatively, you can use redis-cli at the command prompt to confirm that Redis is storing keys properly.
Once you have logged in by typing redis-cli, type KEYS *
This should give you a list of keys related to your CakePHP setup.
An example would be the "myapp_cake_core_object_map" key.
Hope this helps.

Categories