Download the PHP package files.com/files-php-sdk without Composer
On this page you can find all versions of the php package files.com/files-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download files.com/files-php-sdk
More information about files.com/files-php-sdk
Files in files.com/files-php-sdk
Package files-php-sdk
Short Description Files.com PHP SDK
License MIT
Homepage https://www.files.com/
Informations about the package files-php-sdk
Files.com PHP SDK
The Files.com PHP SDK provides convenient Files.com API access to applications written in PHP.
The content included here should be enough to get started, but please visit our Developer Documentation Website for the complete documentation.
Introduction
The Files.com PHP SDK provides convenient access to all of Files.com from applications written in PHP.
You can use it to directly work with files and folders as well as perform management tasks such as adding/removing users, onboarding counterparties, retrieving information about automations and more.
Installation
The Files.com PHP SDK is installed using Composer. See https://packagist.org for more info.
First, install Composer if necessary:
Then use Composer to install the Files.com SDK:
Requirements
- PHP 5.5+
- php-curl extension
Explore the files-sdk-php code on GitHub.
Getting Support
The Files.com Support team provides official support for all of our official Files.com integration tools.
To initiate a support conversation, you can send an Authenticated Support Request or simply send an E-Mail to [email protected].
Authentication
Authenticate with an API Key
Authenticating with an API key is the recommended authentication method for most scenarios, and is the method used in the examples on this site.
To use the API or SDKs with an API Key, first generate an API key from the web interface or via the API or an SDK.
Note that when using a user-specific API key, if the user is an administrator, you will have full access to the entire API. If the user is not an administrator, you will only be able to access files that user can access, and no access will be granted to site administration functions in the API.
Don't forget to replace the placeholder, YOUR_API_KEY
, with your actual API key.
Authenticate with a Session
You can also authenticate to the REST API or SDKs by creating a user session using the username and password of an active user. If the user is an administrator, the session will have full access to the entire API. Sessions created from regular user accounts will only be able to access files that user can access, and no access will be granted to site administration functions.
API sessions use the exact same session timeout settings as web interface sessions. When an API session times out, simply create a new session and resume where you left off. This process is not automatically handled by SDKs because we do not want to store password information in memory without your explicit consent.
Logging In
To create a session, the create
method is called on the \Files\Model\Session
object with the user's username and
password.
This returns a session object that can be used to authenticate SDK method calls.
Using a Session
Once a session has been created, you can store the session globally, use the session per object, or use the session per request to authenticate SDK operations.
Logging Out
User sessions can be ended by calling the Session::destroy
method.
Configuration
Global configuration can be done by setting properties directly on the \Files\Files
class.
Configuration Options
Auto Paginate
Auto-fetch all pages when results span multiple pages. The default value is true
.
Base URL
Setting the base URL for the API is required if your site is configured to disable global acceleration. This can also be set to use a mock server in development or CI.
Log Level
Supported values:
\Files\LogLevel::NONE
\Files\LogLevel::ERROR
\Files\LogLevel::WARN
\Files\LogLevel::INFO
(default)\Files\LogLevel::DEBUG
Debug Requests
Enable debug logging of API requests. The default value is false
.
Debug Response Headers
Enable debug logging of API response headers. The default value is false
.
Connect Timeout
Network connect timeout in seconds. The default value is 30.0.
Read Timeout
Network read timeout in seconds. The default value is 90.
Minimum Retry Delay
Minimum network delay in seconds before retrying. The default value is 0.5.
Maximum Retry Delay
Maximum network delay in seconds before retrying. The default value is 1.5.
Maximum Network Retries
Maximum number of retries. The default value is 3.
Sort and Filter
Several of the Files.com API resources have list operations that return multiple instances of the resource. The List operations can be sorted and filtered.
Sorting
To sort the returned data, pass in the method argument.
Each resource supports a unique set of valid sort fields and can only be sorted by one field at a time.
The argument value is a Php associative array that has a key of the resource field name sort on and a value of either or to specify the sort order.
Filtering
Filters apply selection criteria to the underlying query that returns the results. They can be applied individually or combined with other filters, and the resulting data can be sorted by a single field.
Each resource supports a unique set of valid filter fields, filter combinations, and combinations of filters and sort fields.
The passed in argument value is a Php associative array that has a key of the resource field name to filter on and a passed in value to use in the filter comparison.
Filter Types
Filter | Type | Description |
---|---|---|
filter |
Exact | Find resources that have an exact field value match to a passed in value. (i.e., FIELD_VALUE = PASS_IN_VALUE). |
filter_prefix |
Pattern | Find resources where the specified field is prefixed by the supplied value. This is applicable to values that are strings. |
filter_gt |
Range | Find resources that have a field value that is greater than the passed in value. (i.e., FIELD_VALUE > PASS_IN_VALUE). |
filter_gteq |
Range | Find resources that have a field value that is greater than or equal to the passed in value. (i.e., FIELD_VALUE >= PASS_IN_VALUE). |
filter_lt |
Range | Find resources that have a field value that is less than the passed in value. (i.e., FIELD_VALUE < PASS_IN_VALUE). |
filter_lteq |
Range | Find resources that have a field value that is less than or equal to the passed in value. (i.e., FIELD_VALUE \<= PASS_IN_VALUE). |
Errors
The Files.com PHP SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond to specific errors.
The raised exceptions come from two categories:
- SDK Exceptions - errors that originate within the SDK
- API Exceptions - errors that occur due to the response from the Files.com API. These errors are grouped into common error types.
There are several types of exceptions within each category. Exception classes indicate different types of errors and are named in a
fashion that describe the general premise of the originating error. More details can be found in the exception object message using the
php getMessage()
method call.
Use standard PHP exception handling to detect and deal with errors. It is generally recommended to catch specific errors first, then
catch the general Files\FilesException
exception as a catch-all.
Error Types
SDK Errors
SDK errors are general errors that occur within the SDK code. These errors generate exceptions. Each of these
exception classes inherit from a standard Exception
base class.
SDK Exception Classes
Exception Class Name | Description |
---|---|
ApiBadResponseException |
A bad formed response came back from the API |
ApiConnectException |
The Files.com API cannot be reached |
ApiRequestException |
There was an issue with the API request itself |
ApiServerException |
The API service responded with a bad response (ie, 5xx) |
ApiTooManyRedirectsException |
The API service redirected too many times |
ConfigurationException |
Invalid SDK configuration parameters |
EmptyPropertyException |
An required property was empty |
InvalidParameterException |
A passed in parameter is invalid |
MissingParameterException |
A method parameter is missing |
NotImplementedException |
The called method has not be implemented by the SDK |
API Errors
API errors are errors returned by the Files.com API. Each exception class inherits from an error group base class. The error group base class indicates a particular type of error.
API Exception Classes
Exception Class Name | Error Group |
---|---|
AgentUpgradeRequiredException |
BadRequestException |
AttachmentTooLargeException |
BadRequestException |
CannotDownloadDirectoryException |
BadRequestException |
CantMoveWithMultipleLocationsException |
BadRequestException |
DatetimeParseException |
BadRequestException |
DestinationSameException |
BadRequestException |
FolderMustNotBeAFileException |
BadRequestException |
FoldersNotAllowedException |
BadRequestException |
InvalidBodyException |
BadRequestException |
InvalidCursorException |
BadRequestException |
InvalidCursorTypeForSortException |
BadRequestException |
InvalidEtagsException |
BadRequestException |
InvalidFilterAliasCombinationException |
BadRequestException |
InvalidFilterFieldException |
BadRequestException |
InvalidFilterParamException |
BadRequestException |
InvalidFilterParamValueException |
BadRequestException |
InvalidInputEncodingException |
BadRequestException |
InvalidInterfaceException |
BadRequestException |
InvalidOauthProviderException |
BadRequestException |
InvalidPathException |
BadRequestException |
InvalidReturnToUrlException |
BadRequestException |
InvalidSortFilterCombinationException |
BadRequestException |
InvalidUploadOffsetException |
BadRequestException |
InvalidUploadPartGapException |
BadRequestException |
InvalidUploadPartSizeException |
BadRequestException |
MethodNotAllowedException |
BadRequestException |
NoValidInputParamsException |
BadRequestException |
PartNumberTooLargeException |
BadRequestException |
PathCannotHaveTrailingWhitespaceException |
BadRequestException |
ReauthenticationNeededFieldsException |
BadRequestException |
RequestParamsContainInvalidCharacterException |
BadRequestException |
RequestParamsInvalidException |
BadRequestException |
RequestParamsRequiredException |
BadRequestException |
SearchAllOnChildPathException |
BadRequestException |
UnsupportedCurrencyException |
BadRequestException |
UnsupportedHttpResponseFormatException |
BadRequestException |
UnsupportedMediaTypeException |
BadRequestException |
UserIdInvalidException |
BadRequestException |
UserIdOnUserEndpointException |
BadRequestException |
UserRequiredException |
BadRequestException |
AdditionalAuthenticationRequiredException |
NotAuthenticatedException |
AuthenticationRequiredException |
NotAuthenticatedException |
BundleRegistrationCodeFailedException |
NotAuthenticatedException |
FilesAgentTokenFailedException |
NotAuthenticatedException |
InboxRegistrationCodeFailedException |
NotAuthenticatedException |
InvalidCredentialsException |
NotAuthenticatedException |
InvalidOauthException |
NotAuthenticatedException |
InvalidOrExpiredCodeException |
NotAuthenticatedException |
InvalidSessionException |
NotAuthenticatedException |
InvalidUsernameOrPasswordException |
NotAuthenticatedException |
LockedOutException |
NotAuthenticatedException |
LockoutRegionMismatchException |
NotAuthenticatedException |
OneTimePasswordIncorrectException |
NotAuthenticatedException |
TwoFactorAuthenticationErrorException |
NotAuthenticatedException |
TwoFactorAuthenticationSetupExpiredException |
NotAuthenticatedException |
ApiKeyIsDisabledException |
NotAuthorizedException |
ApiKeyIsPathRestrictedException |
NotAuthorizedException |
ApiKeyOnlyForDesktopAppException |
NotAuthorizedException |
ApiKeyOnlyForMobileAppException |
NotAuthorizedException |
ApiKeyOnlyForOfficeIntegrationException |
NotAuthorizedException |
BillingOrSiteAdminPermissionRequiredException |
NotAuthorizedException |
BillingPermissionRequiredException |
NotAuthorizedException |
BundleMaximumUsesReachedException |
NotAuthorizedException |
CannotLoginWhileUsingKeyException |
NotAuthorizedException |
CantActForOtherUserException |
NotAuthorizedException |
ContactAdminForPasswordChangeHelpException |
NotAuthorizedException |
FilesAgentFailedAuthorizationException |
NotAuthorizedException |
FolderAdminOrBillingPermissionRequiredException |
NotAuthorizedException |
FolderAdminPermissionRequiredException |
NotAuthorizedException |
FullPermissionRequiredException |
NotAuthorizedException |
HistoryPermissionRequiredException |
NotAuthorizedException |
InsufficientPermissionForParamsException |
NotAuthorizedException |
InsufficientPermissionForSiteException |
NotAuthorizedException |
MustAuthenticateWithApiKeyException |
NotAuthorizedException |
NeedAdminPermissionForInboxException |
NotAuthorizedException |
NonAdminsMustQueryByFolderOrPathException |
NotAuthorizedException |
NotAllowedToCreateBundleException |
NotAuthorizedException |
PasswordChangeNotRequiredException |
NotAuthorizedException |
PasswordChangeRequiredException |
NotAuthorizedException |
ReadOnlySessionException |
NotAuthorizedException |
ReadPermissionRequiredException |
NotAuthorizedException |
ReauthenticationFailedException |
NotAuthorizedException |
ReauthenticationFailedFinalException |
NotAuthorizedException |
ReauthenticationNeededActionException |
NotAuthorizedException |
RecaptchaFailedException |
NotAuthorizedException |
SelfManagedRequiredException |
NotAuthorizedException |
SiteAdminRequiredException |
NotAuthorizedException |
SiteFilesAreImmutableException |
NotAuthorizedException |
TwoFactorAuthenticationRequiredException |
NotAuthorizedException |
UserIdWithoutSiteAdminException |
NotAuthorizedException |
WriteAndBundlePermissionRequiredException |
NotAuthorizedException |
WritePermissionRequiredException |
NotAuthorizedException |
ZipDownloadIpMismatchException |
NotAuthorizedException |
ApiKeyNotFoundException |
NotFoundException |
BundlePathNotFoundException |
NotFoundException |
BundleRegistrationNotFoundException |
NotFoundException |
CodeNotFoundException |
NotFoundException |
FileNotFoundException |
NotFoundException |
FileUploadNotFoundException |
NotFoundException |
FolderNotFoundException |
NotFoundException |
GroupNotFoundException |
NotFoundException |
InboxNotFoundException |
NotFoundException |
NestedNotFoundException |
NotFoundException |
PlanNotFoundException |
NotFoundException |
SiteNotFoundException |
NotFoundException |
UserNotFoundException |
NotFoundException |
AlreadyCompletedException |
ProcessingFailureException |
AutomationCannotBeRunManuallyException |
ProcessingFailureException |
BehaviorNotAllowedOnRemoteServerException |
ProcessingFailureException |
BundleOnlyAllowsPreviewsException |
ProcessingFailureException |
BundleOperationRequiresSubfolderException |
ProcessingFailureException |
CouldNotCreateParentException |
ProcessingFailureException |
DestinationExistsException |
ProcessingFailureException |
DestinationFolderLimitedException |
ProcessingFailureException |
DestinationParentConflictException |
ProcessingFailureException |
DestinationParentDoesNotExistException |
ProcessingFailureException |
ExpiredPrivateKeyException |
ProcessingFailureException |
ExpiredPublicKeyException |
ProcessingFailureException |
ExportFailureException |
ProcessingFailureException |
ExportNotReadyException |
ProcessingFailureException |
FailedToChangePasswordException |
ProcessingFailureException |
FileLockedException |
ProcessingFailureException |
FileNotUploadedException |
ProcessingFailureException |
FilePendingProcessingException |
ProcessingFailureException |
FileProcessingErrorException |
ProcessingFailureException |
FileTooBigToDecryptException |
ProcessingFailureException |
FileTooBigToEncryptException |
ProcessingFailureException |
FileUploadedToWrongRegionException |
ProcessingFailureException |
FilenameTooLongException |
ProcessingFailureException |
FolderLockedException |
ProcessingFailureException |
FolderNotEmptyException |
ProcessingFailureException |
HistoryUnavailableException |
ProcessingFailureException |
InvalidBundleCodeException |
ProcessingFailureException |
InvalidFileTypeException |
ProcessingFailureException |
InvalidFilenameException |
ProcessingFailureException |
InvalidPriorityColorException |
ProcessingFailureException |
InvalidRangeException |
ProcessingFailureException |
ModelSaveErrorException |
ProcessingFailureException |
MultipleProcessingErrorsException |
ProcessingFailureException |
PathTooLongException |
ProcessingFailureException |
RecipientAlreadySharedException |
ProcessingFailureException |
RemoteServerErrorException |
ProcessingFailureException |
ResourceLockedException |
ProcessingFailureException |
SubfolderLockedException |
ProcessingFailureException |
TwoFactorAuthenticationCodeAlreadySentException |
ProcessingFailureException |
TwoFactorAuthenticationCountryBlacklistedException |
ProcessingFailureException |
TwoFactorAuthenticationGeneralErrorException |
ProcessingFailureException |
TwoFactorAuthenticationMethodUnsupportedErrorException |
ProcessingFailureException |
TwoFactorAuthenticationUnsubscribedRecipientException |
ProcessingFailureException |
UpdatesNotAllowedForRemotesException |
ProcessingFailureException |
DuplicateShareRecipientException |
RateLimitedException |
ReauthenticationRateLimitedException |
RateLimitedException |
TooManyConcurrentLoginsException |
RateLimitedException |
TooManyConcurrentRequestsException |
RateLimitedException |
TooManyLoginAttemptsException |
RateLimitedException |
TooManyRequestsException |
RateLimitedException |
TooManySharesException |
RateLimitedException |
AgentUnavailableException |
ServiceUnavailableException |
AutomationsUnavailableException |
ServiceUnavailableException |
MigrationInProgressException |
ServiceUnavailableException |
SiteDisabledException |
ServiceUnavailableException |
UploadsUnavailableException |
ServiceUnavailableException |
AccountAlreadyExistsException |
SiteConfigurationException |
AccountOverdueException |
SiteConfigurationException |
NoAccountForSiteException |
SiteConfigurationException |
SiteWasRemovedException |
SiteConfigurationException |
TrialExpiredException |
SiteConfigurationException |
TrialLockedException |
SiteConfigurationException |
UserRequestsEnabledRequiredException |
SiteConfigurationException |
Examples
Static File Operations
List Files in Root Folder
Uploading a File on Disk
If the parent directories do not already exist, they can be automatically created by passing mkdir_parents
in the params
.
Writing a File
Reading a File to Stream
Download a File to Disk
Getting a File Record by Path
File Object Operations
Getting a File Record by Path
Updating Metadata
Retrieving Metadata
Comparing Case-Insensitive Files and Paths
For related documentation see Case Sensitivity Documentation.
Mock Server
Files.com publishes a Files.com API server, which is useful for testing your use of the Files.com SDKs and other direct integrations against the Files.com API in an integration test environment.
It is a Ruby app that operates as a minimal server for the purpose of testing basic network operations and JSON encoding for your SDK or API client. It does not maintain state and it does not deeply inspect your submissions for correctness.
Eventually we will add more features intended for integration testing, such as the ability to intentionally provoke errors.
Download the server as a Docker image via Docker Hub.
The Source Code is also available on GitHub.
A README is available on the GitHub link.
Upgrading
Upgrading to Version 2.0 from previous versions
In Version 2.0, the Files.com PHP SDK was updated to comply with both the PSR-12 coding standard and the PSR-4 autoloading standard. No new classes were added or any existing classes removed, but some were moved to comply with the PSR-4 standard. If a client of the sdk references the moved classes, the client code will need to be updated to reference the new location of these classes.
Exception Classes
The affected classes were primarily Exception classes. Exceptions were moved into their own namespace (and source files).
The following table shows the classes that were changed for compliance
Base Exceptions
The Base exception were moved from the \Files
namespace to the \Files\Exception
namespace.
Examples of Base Exceptions Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\ApiException |
Files\Exception\ApiException |
\Files\FilesException |
Files\Exception\FilesException |
\Files\ConfigurationException |
Files\Exception\ConfigurationException |
BadRequest Exceptions
The BadRequest group of exceptions were moved from the \Files\BadRequest
namespace to the \Files\Exception\BadRequest
namespace.
Example of BadRequest Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\BadRequest\AgentUpgradeRequiredException |
Files\Exception\BadRequest\AgentUpgradeRequiredException |
NotAuthenticated Exceptions
The NotAuthenticated group of exceptions were moved from the
\Files\NotAuthenticated
namespace to the \Files\Exception\NotAuthenticated
namespace.
Example of NotAuthenticated Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\NotAuthenticated\AdditionalAuthenticationRequiredException |
Files\Exception\NotAuthenticated\AdditionalAuthenticationRequiredException |
NotAuthorized Exceptions
The NotAuthorized group of exceptions were moved from the \Files\NotAuthorized
namespace to the \Files\Exception\NotAuthorized
namespace.
Example of NotAuthorized Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\NotAuthorized\ApiKeyIsDisabledException |
Files\Exception\NotAuthorized\ApiKeyIsDisabledException |
NotFound Exceptions
The NotFound group of exceptions were moved from the \Files\NotFound
namespace to the \Files\Exception\NotFound
namespace.
Example of NotFound Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\NotFound\ApiKeyNotFoundException |
Files\Exception\NotFound\ApiKeyNotFoundException |
ProcessingFailure Exceptions
The ProcessingFailure group of exceptions were moved from the
\Files\ProcessingFailure
namespace to the \Files\Exception\ProcessingFailure
namespace.
Example of ProcessingFailure Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\ProcessingFailure\AlreadyCompletedException |
Files\Exception\ProcessingFailure\AlreadyCompletedException |
RateLimited Exceptions
The ProcessingFailure group of exceptions were moved from the
\Files\RateLimited
namespace to the \Files\Exception\RateLimited
namespace.
Example of RateLimited Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\RateLimited\DuplicateShareRecipientException |
Files\Exception\RateLimited\DuplicateShareRecipientException |
ServiceUnavailable Exceptions
The ServiceUnavailable group of exceptions were moved from the
\Files\ServiceUnavailable
namespace to the
\Files\Exception\ServiceUnavailable
namespace.
Example of ServiceUnavailable Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\ServiceUnavailable\AgentUnavailableException |
Files\Exception\ServiceUnavailable\AgentUnavailableException |
SiteConfiguration Exceptions
The SiteConfiguration group of exceptions were moved from the
\Files\SiteConfiguration
namespace to the \Files\Exception\SiteConfiguration
namespace.
Example of SiteConfiguration Classes moved.
SDK < 2.0 Class Location | SDK >= 2.0 Class Location |
---|---|
\Files\SiteConfiguration\AccountAlreadyExistsException |
Files\Exception\SiteConfiguration\AccountAlreadyExistsException |
All versions of files-php-sdk with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
ext-intl Version *
guzzlehttp/guzzle Version ^6 || ^7