I'm trying to load a custom class (google_auth.class.php) with the composer autoload.
This is my structure file:
/vendor
/lib/src/google_auth.class.php
index.php
autoload.php';
this is autoload.php
<?php
return require __DIR__ . '/vendor/autoload.php';
?>
This is my index.php code:
<?php
$autoloader = require_once 'autoload.php';
require_once 'init.php';
$googleClient = new Google_Client();
$auth = new GoogleOauthClass($googleClient);
?>
I add this code to my composer.json:
"autoload":{
"psr-4":{
"GoogleOauth\\": "lib/src/"
}
}
And run composer dump-autoload
If I execute: php index.php
I get this message:
PHP Fatal error: Class 'GoogleOauthClass' not found in /home/oskar/webapps/sourcecode/googlelogin/index.php on line 19
If I add to the files this line:
require_once ('lib/src/google_auth.class.php');
It works fine.
Thanks.
Oskar