PHP code example of buse974 / dms

1. Go to this page and download the library: Download buse974/dms 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/ */

    

buse974 / dms example snippets





return array(
    'modules' => array(
        'Dms',
    ),
    'module_paths' => array(
       'Dms' => __DIR__ . '/../vendor/buse974/dms',
    ),
),
);

'dms-conf' => array(
    /*
     * Allowed sizes - You can add as many as you need
     */
    'size_allowed' => array(                    
                array('width' => 300, 'height' => 200),
                array('width' => 300, 'height' => 300),
                array('width' => 150, 'height' => 100),
                array('width' => 80, 'height' => 80),
                array('width' => 300),
        ),
        /*
         * path where all the documents will be uploaded
         */
        'default_path' => 'upload/',      
        /*
         * http adapter - You have to add your [http adapter](#HTTP-adapter) 
         * in your config/autoloader/local.php or config/autoloader/global.php
         * If you already have a http adapter, please just specify its name
         */
        'adapter' => 'http-adapter',             
        'convert' => array(
                /* 
                 * path where you want to convert and stock the temporaries files
                 * !! apache need all rights for writing and reading on this directory !!
                 */
                'tmp' => '/tmp/',    
        ),
        /*
         * the headers to add to your files - especially for cross-domain
         */
        'headers'=> array(                        
                'Access-Control-Allow-Origin'=>'http://local.wow.in',
                'Access-Control-Allow-Credentials'=>'true'
        ),
),

'http-adapter' => array(
        'adapter' => 'Zend\Http\Client\Adapter\Socket',
        'maxredirects'   => 5,
        'timeout'        => 10,
        'sslverifypeer' => false,
),

$manager = $this->serviceManager->get('dms.service');

/*
 *  exemple
 */
$image = file_get_contents(__DIR__ . '/../../_file/gnu.png');

/*
 * string - document's codings specified in `dma/coding/CodingInterface`
 */
$document['coding'] = 'base';  

/*
 * mime-type
 */
$document['type'] = 'image/png';  

/*
 * datas with specified encoding
 * if you choose url coding, you can add the picture url which will be uploaded and saved
 */
$document['data'] =  base64_encode($image);        

/*
 * Return the document's token
 */
$token = $manager->add($document);   

/*
 *  width x height in a string - Return a new token for the document resized
 */
$new_token = $manager->resize('80x80');    


$manager = $this->serviceManager->get('dms.manager');

/*
 * file exemple
 */
$image = file_get_contents(__DIR__ . '/../../_file/gnu.png');

$document = new Dms\Document\Document();
$document->setDatas($image); 
$document->setFormat('png');            


$manager->loadDocument($document);  

$manager->setFormat('jpg');
$manager->setSize('80x80'); 
$manager->writeFile();

/*
 * Get the document
 */
$document = $manager->getDocument();

/*
 * Return the document's token
 */
$token = $document->getId();