1. Go to this page and download the library: Download phine/compact 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/ */
phine / compact example snippets
use Phine\Compact\Json;
$compactor = new Json();
echo $compactor->compactFile('example.json');
// which is also the same as
echo $compactor->compactContents(file_get_contents('example.json'));
use Phine\Compact\AbstractCompact;
/**
* Simply trims all lines.
*/
class Trim extends AbstractCompact
{
/**
* {@inheritDoc}
*/
public function compactContents($contents)
{
$contents = preg_replace('/^\s+/m', '', $contents);
$contents = preg_replace('/\s+$/m', '', $contents);
return $contents;
}
}
use Phine\Compact\Collection;
use Phine\Compact\Json;
use Phine\Compact\Php;
use Phine\Compact\Xml;
$collection = new Collection();
$collection->addCompactor(new Json());
$collection->addCompactor(new Php());
$collection->addCompactor(new Xml());
$json = <<<JSON
{
"key": "value"
}
JSON;
echo $collection->getCompactor('json')->compactContents($json);
// {"key":"value"}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.