Laravel Developer
David Carr
Web Developer
All Posts Archives Categories Authors
About Books Packages Templates Contact
Blog
All Posts Archives Categories Authors
About Books Packages Templates Contact
Laravel Box
Laravel Packages
Laravel Microsoft Graph Laravel Xero Laravel Sent Emails Laravel Dropbox Laravel Box Laravel Companies House Laravel Countries Laravel Eventbrite Laravel Blade Components
PHP Packages
PDO Wrapper PHP find and replace JSON SQL Import IMAP Export CSV Pagination
v1
Navigation
  • Introduction
  • Install
  • Files
  • Folders
Navigation
  • Introduction
  • Install
  • Files
  • Folders

Install

Application Register

To use Box API an application needs creating at https://app.box.com/developers/console/newapp

Select the type of application. Select custom if you need to access the API abilities. Select the Oauth2 app type after selecting custom.

Install

Via Composer

composer require dcblogdev/laravel-box

Config

You can publish the config file with:

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

When published, the config/box.php config file contains:

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',
];

Migration

You can publish the migration with:

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

After the migration has been published you can create the tokens tables by running the migration:

php artisan migrate

.ENV Configuration

You should add the env variables to your .env file, this allows you to use a different box application on different servers, each box application requires a unique callback URL.

The following are required when using OAuth 2.0 credentials:

The BOX_REDIRECT_URI is where Box should redirect to for authentication with Box, upon successful authentication the BOX_LANDING_URI is used to direct a user to the desired page. > Note BOX_REDIRECT_URI needs to be the full URI ie https://domain.com/box/

BOX_CLIENT_ID=
BOX_SECRET_ID=
BOX_REDIRECT_URI=https://domain.com/box/oauth
BOX_LANDING_URI=https://domain.com/box
Table of Contents
  • Application Register
  • Install
    • Via Composer
    • Config
    • Migration
    • .ENV Configuration

DCBlog

Practical tutorials, code snippets, and in-depth guides for modern web development. Helping developers build better applications since 2009.

Subscribe to my newsletter for the latest updates on my books and digital products.

© 2009 - 2025 DC Blog. All rights reserved.

Privacy Policy • Terms of Service