asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
544 stars 152 forks source link

How to use without install #67

Closed strech345 closed 9 years ago

strech345 commented 9 years ago

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

piupiupiu commented 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);
strech345 commented 9 years ago

Yes, i mean without composer. Thanks! I will check it out the next days.

asimlqt commented 9 years ago

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.

ByteToByte commented 8 years ago

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');