Class 'Google_Client' not found in cake php - cakephp

I am working on google login in cake PHP. And I got one error while clicking on Google sign-in button.
"Class 'Google_Client' not found".
Can you help me how to solve this in cake PHP? I am new to CakePHP.
public function googlelogin(){
App::uses('Google_Client', 'Google');
$client = new Google_Client();
dd($client);
$client->setClientId(Configure::read('Google.googleClientID'));
$client->setClientSecret(Configure::read('Google.googleClientSecret'));
$client->setRedirectUri(Configure::read('Google.googleRedirectUrl'));
$client->setScopes([
"https://www.googleapis.com/auth/userinfo.profile",
'https://www.googleapis.com/auth/userinfo.email'
]);
$url = $client->createAuthUrl();
$this->redirect($url);
}
Version . 2.8

Related

laravel dusk facebook web driver and cookies

i was trying to login to a site with facebook chrome driver
and then visit another path of the website after login
login is successful but when I try to view another page
it dont recognize my login
here is my code :
$process = (new ChromeProcess)->toProcess();
$process->start();
$options = (new ChromeOptions)->addArguments(['--disable-gpu', '--headless','--enable-file-cookies','--disable-web-security','--allow-file-access-from-files']);
$capabilities = DesiredCapabilities::chrome()->setCapability(ChromeOptions::CAPABILITY, $options);
$driver = retry(5, function () use ($capabilities) {
return RemoteWebDriver::create('http://localhost:9515', $capabilities);
}, 50);
$browser = new Browser($driver);
$browser::$baseUrl = 'https://example.com';
$browser->visit('/login')
->type('username','1375344')
->type('password','23444')
->press('.login_btn');
$browser->waitForText('welcome');
$browser->visit('/statement/deposit/view');
$browser->dump();
does laravel dusk and/or facebook driver has something like cookiejar?
Try
$browser->loginAs(User::find(1));
Additionally you can look at
Dusk Authentication

UserLogin function in Joomla 3.x

Please can anyone tell the new login function used in Joomla 3.5 and above. I found this particular method in previous version of Joomla which fires on login.
class PlgUserAddInfo extends JPlugin
{
public function onUserLogin($user, $options = array())
{
$user = JFactory::getUser();
$mysignum = $user->username;
$session = JFactory::getSession();
$session->set('sign', $sign);
}
}
In Joomla 2.5 function onUserLogin() is used for your purpose. But in latest Joomla version 3.5 function onUserAfterLogin() is used.
You can also follow the link https://docs.joomla.org/Plugin/Events/User#onUserAfterLogin for more reference.

CakePHP - Class 'AuthComponent' not found in cached view

I'm using CakePHP 2.3. and I'm trying to cache my home page view. But After caching
it to home.php, I can't load cached view because of error:
Error: Class 'AuthComponent' not found
File: C:\wamp\www\project\trunk\app\tmp\cache\views\home.php
Line: 87
I use AuthComponent for realizing if user is logged in or not. Without caching Everything works.
Controller code:
public $helpers = array('Cache');
public $cacheAction = array(
'home' => '60 minutes',
);
Thanks
App::uses() your Auth component in your bootstrap would help:
App::uses('AuthComponent', 'Controller/Component');
This way Cake knows where to load the class from if its needed (even in cache mode).
That would be this line in the file \config\bootstrap.php
App::uses('AuthComponent', 'Controller/Component');
Note that I tried this in Cake 4.1.5 but it tlls me "Class 'AuthComponent' not found"

cakephp REST problem

** SOLUTION **
I am using cakephp 1.3. I did not have to add any routes. All i did is after adding the action to the controller, I went to the url
/controller/action/id
in my case it was
/test/bravo/123
and that did the trick
** End **
I am using cakephp 1.3 and I am trying to add webservice. I heard its very easy to add restful. What I want to do is to have one of the actions in my controller provoked and log into a logfile as a success. Lets say
function bravo(){ $this->log("success", "Testlog");
So far I went through documentation and added the following to my routes.php
Router::mapResources('tests');
Router::parseExtensions();
then in test controller I have this
<?php
class TestsController extends AppController {
var $name = 'Tests';
var $components = array('RequestHandler');
.....
.....
function bravo(){
$this->log("success", "Testlog");
}
?>
Now when I go to
/tests.bravo
, its not logging the success in the log file. What am I doing wrong. Thanks

ControllerFile not found error in cakephp

HI! I'm trying to create the web service in the cakePhp. I'm new to cakePhp and only recently start working on it. I found a useful tutorial at http://www.littlehart.net/atthekeyboard/2007/03/13/how-easy-are-web-services-in-cakephp-12-really-easy/
I created both the controller and index.ctp files as described in the tutorial. But when I typed the url (http://localhost:81/cakephp/foo) of the controller to run the file, I got the following error:
// controllers/recipes_controller.php
/**
* Test controller for built-in web services in Cake 1.2.x.x
*
* #author Chris Hartjes
*
*/
class FooController extends AppController {
var $components = array('RequestHandler');
var $uses = '';
var $helpers = array('Text', 'Xml');
function index() {
$message = 'Testing';
$this->set('message', $message);
$this->RequestHandler->respondAs('xml');
$this->viewPath .= '/xml';
$this->layoutPath = 'xml';
}
}
CakePHP: the rapid development php framework
Missing Controller
Error: FooController could not be found.
Error: Create the class FooController below in file: app\controllers\foo_controller.php
Strange thing is that (everyone can see) that controller text is loaded in the error page, but error shows that controller file is not found.
I also tried to follow the tutorial on book.cakephp.org/view/477/The-Simple-Setup.
But same error also occured here. Anyone can help? By the way I also changed the text of routes.php to work it with web webservices.
Thanks
The fact that the contents of your FooController file is being output in the browser indicates that the PHP is not being executed.
You need to ensure that the definition for your FooController class is enclosed in <?php and ?> tags, like this:
// controllers/recipes_controller.php
/**
* Test controller for built-in web services in Cake 1.2.x.x
*
* #author Chris Hartjes
*
*/
<?php
class FooController extends AppController {
var $components = array('RequestHandler');
var $uses = '';
var $helpers = array('Text', 'Xml');
function index() {
$message = 'Testing';
$this->set('message', $message);
$this->RequestHandler->respondAs('xml');
$this->viewPath .= '/xml';
$this->layoutPath = 'xml';
}
}
?>
You have entered the URL http://localhost:81/cakephp/foo. Cake correctly interprets this to mean you are looking for the index action on the FooController. The error doesn't mean it has found the file, just that it has worked out what to look for but hasn't found it where it expects it to be.
The line: Error: Create the class FooController below in file: app\controllers\foo_controller.php tells you what should be there (and what, as a minimum, it should look like). Check that you have named the file correctly and that it located where the error says it should be.

Resources