How to Use GroupDocs PHP SDK with Composer or a Built-in Autoloader
supports all major platforms, such as .NET, PHP, Java, Python, etc. So with GropDocs’ SDKs you can easily create your own application to store, view, sign (and use a lot of other great features on) your documents online, using Windows or Linux with your favorite language.
Today, I’ll talk about GroupDocs PHP SDK and how to get started with it. Sometimes, developers ask us how to get our PHP SDK, how to use it with Composer, or how to include it into their project. As we all know, a good beginning is a half the job. So this is how to start developing with the PHP SDK more quickly and efficiently.
Getting and Using the SDK
There are different ways to get PHP SDK. I’ll show how to get it and then include it into a PHP application.
Manual Download from GitHub
- Clone our PHP SDK repo from GitHub (repository is here: https://github.com/groupdocs/groupdocs-php).
- Copy all files from the src folder (or the entire src folder with files) into the project.
- Include our main API file:require_once _DIR_.'/src/APIClient.php';
After this you can use classes.
$signer = new GroupDocsRequestSigner(12345);
$apiClient = new APIClient($signer);
Getting GroupDocs PHP SDK with Composer and using its Autoloader
Composer is a great tool that helps you get and use PHP libraries easily. There is only one issue for developers that are not familiar with Composer: how to get and use it. But it’s very easy! There are tons of information about this on the Internet, so I’ll provide a sample for Linux users that shows how to:
- Get Composer,
- download GroupDocs PHP SDK with it, and, finally,
- use the autoloader generated by Composer.
Downloading Composer and GroupDocs PHP SDK
For example, to download Composer and the PHP SDK into the sdktest
folder in the user’s folder (~):
- cd ~
- mkdir sdktest
- cd sdktest
- curl -s http://getcomposer.org/installer | php
- gedit composer.json
(This create the composer.json file, you should use your editor: vi for example.)
- Source for composer.json file:
- php composer.phar install
Composer downloads the last version of the GroupDocs PHP SDK and (very important!) creates an autoloader. You can find it in the vendor folder.
- Copy all the files in the vendor folder (or the folder itself) and include the autoload.php file into your web app script. (For example: require_once_DIR_.'/vendor/autoload.php';).
After this, all methods and classes are available to your script. Some frameworks can work with Composer and its autoloader and include it automatically.
So now you know how to get GroupDocs PHP SDK and are ready to start coding your own web oriented Document Management solution
with GroupDocs PHP SDK. Thanks for reading our Tech Blog.