PHP code example of dcblogdev / laravel-box

1. Go to this page and download the library: Download dcblogdev/laravel-box library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dcblogdev / laravel-box example snippets


return [
    'clientId'       => env('BOX_CLIENT_ID'),
    'clientSecret'   => env('BOX_SECRET_ID'),
    'redirectUri'    => env('BOX_REDIRECT_URI'),
    'boxLandingUri'  => env('BOX_LANDING_URI'),
    'urlAuthorize'   => 'https://account.box.com/api/oauth2/authorize',
    'urlAccessToken' => 'https://www.box.com/api/oauth2/token',
];

use Dcblogdev\Box\Facades\Box;

Route::get('box', function() {

    //if no box token exists then redirect
    Box::getAccessToken(); 
    
    //box authenticated now box:: can be used freely.

    //example of getting the authenticated users details
    return Box::get('/users/me');
    
});

Route::get('box/oauth', function() {
    return Box::connect();
});

Box::get('users/me');

Box::post('folders', [
    'name' => 'name of the folder',
    'parent' => [
        'id' => 0
    ]
]);

Box::get('path', $array);
Box::post('path', $array);
Box::put('path', $array);
Box::patch('path', $array);
Box::delete('path', $array);

Box::files()->file($id);

Box::files()->download($id, $path = '', $storeDownload = false);

Box::files()->upload($path, $name, $parent = 0);

Box::files()->uploadRevision($file_id, $filepath, $name, $newname = null);

Box::files()->destroy($id);

php artisan vendor:publish --provider="Dcblogdev\Box\BoxServiceProvider" --tag="config"

php artisan vendor:publish --provider="Dcblogdev\Box\BoxServiceProvider" --tag="migrations"

php artisan migrate