Closed strech345 closed 9 years ago
Hi.
Do you mean load the files without composer? I mean the old school way. If so, there are two possible solutions:
1) Require them one by one using require_once
.
2) Put Spreadsheets directory to src/Google
directory and modify autoload.php
file from google-api-php-client-master
as follows:
if (preg_match("/_/",$className)) {
$classPath = explode('_', $className);
} else {
$classPath = explode('\\', $className);
}
Then use in your code as follows:
$serviceRequest = new Google\Spreadsheet\DefaultServiceRequest($accessToken);
Yes, i mean without composer. Thanks! I will check it out the next days.
It's best to install it via composer. You don't need root access to use composer or did you mean you don't have ssh access?
If you're really struggling to find a decent solution as a last resort, you can install it via composer in your project on your local machine and commit it to your repository as you would with any other of your custom code.
This solution without composer (works in class)
define('DOCROOT', dirname(__FILE__));
use Google\Spreadsheet\DefaultServiceRequest;
use Google\Spreadsheet\ServiceRequestFactory;
if(!function_exists('classAutoLoader')){
function classAutoLoader($class_name) {
$class_name = str_replace('\\','/',$class_name);
require_once(DOCROOT."/src/".$class_name.".php");
}
}
spl_autoload_register('classAutoLoader');
Hello, i don't have the root permission on the server. so, it is possible to copy paste the php files next to the google-api-php-client-master files an run without installation like other php frameworks? Thanks Stephan