1. Go to this page and download the library: Download kompakt/b3d 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/ */
kompakt / b3d example snippets
use GuzzleHttp\Client;
use Kompakt\B3d\Details\Endpoint\Resource\Artist\Endpoint;
$artistEndpoint = new Endpoint(
new Client(),
'<artist-endpoint-url>',
'<api-key>'
);
$rawArtistData = $artistEndpoint->fetchAll();
use Kompakt\B3d\Details\Endpoint\Cache\PhpFile\Serializer;
use Kompakt\B3d\Util\File\Writer;
$artistSerializer = new Serializer(
new Writer(),
'path/to/artist/data/file'
);
$artistSerializer->serialize($rawArtistData);
use Kompakt\B3d\Details\Endpoint\Resource\Artist\Mapper;
use Kompakt\B3d\Details\Entity\Artist;
use Kompakt\B3d\Details\Repository\ArtistRepository;
use Kompakt\B3d\Util\File\Reader;
use Kompakt\B3d\Details\Populator\Cache\PhpFile\Populator;
$artistPopulator = new Populator(
new ArtistMapper(new Artist()),
new ArtistRepository(),
new Reader(),
'path/to/artist/data/file'
);
$artistRepository = $artistPopulator->populate();
$artists = $artistRepository->getAll();
use Kompakt\B3d\Details\Endpoint\Resource\Artist\Mapper;
use Kompakt\B3d\Details\Entity\Artist;
use Kompakt\B3d\Details\Repository\ArtistRepository;
use Kompakt\B3d\Details\Populator\Endpoint\Populator;
$artistPopulator = new Populator(
new ArtistMapper(new Artist()),
new ArtistRepository(),
$artistEndpoint
);
use Kompakt\B3d\Details\Graph\Loader as GraphLoader;
$graphLoader = new GraphLoader(
$artistPopulator,
$labelPopulator,
$pricePopulator,
$productPopulator,
$productTrackPopulator,
$releasePopulator,
$trackPopulator
);
$releaseRepository = $graphLoader->load();
use Kompakt\B3d\Canonical\Dom\Product\Builder as CanonicalProductDomBuilder;
use Kompakt\B3d\Canonical\Entity\Price as CanonicalPrice;
use Kompakt\B3d\Canonical\Entity\Product as CanonicalProduct;
use Kompakt\B3d\Canonical\Entity\Track as CanonicalTrack;
use Kompakt\B3d\Canonical\Converter\Details\ConverterRunner;
use Kompakt\B3d\Canonical\Converter\Details\Product as CanonicalProductConverter;
use Kompakt\B3d\Canonical\Converter\Details\Subscriber\XmlSerializer as XmlSerializerSubscriber;
use Kompakt\B3d\Util\File\Writer;
use Kompakt\CollectionRunner\EventNames;
use Kompakt\CollectionRunner\Runner as CollectionRunner;
use Symfony\Component\EventDispatcher\EventDispatcher;
$dispatcher = new EventDispatcher();
$eventNames = new EventNames();
$collectionRunner = new CollectionRunner($dispatcher, $eventNames);
$canonicalProductConverter = new CanonicalProductConverter(
new CanonicalProduct(),
new CanonicalTrack(),
new CanonicalPrice()
);
$canonicalProductXmlSerializer = new CanonicalProductXmlSerializer(
new CanonicalProductDomBuilder(),
new Writer(),
'path/to/xml/output/dir'
);
$serializerSubscriber = new XmlSerializerSubscriber(
$dispatcher,
$eventNames,
$canonicalProductXmlSerializer
);
$converterRunner = new ConverterRunner(
$collectionRunner,
$graphLoader,
$canonicalProductConverter
);
$serializerSubscriber->activate();
$converterRunner->load();
$converterRunner->run();
use Kompakt\B3d\Canonical\Dom\Product\Mapper as DomProductMapper;
use Kompakt\B3d\Canonical\Entity\Price;
use Kompakt\B3d\Canonical\Entity\Product;
use Kompakt\B3d\Canonical\Entity\Track;
use Kompakt\B3d\Canonical\Populator\Xml\Subscriber\Product as Populator;
use Kompakt\B3d\Canonical\Repository\ProductRepository;
use Kompakt\B3d\Canonical\Unserializer\Xml\Product as Unserializer;
use Kompakt\B3d\Util\Dom\Loader as DomLoader;
use Kompakt\B3d\Util\File\Reader;
use Kompakt\DirectoryRunner\Runner;
use Kompakt\DirectoryRunner\EventNames;
use Kompakt\DirectoryRunner\Subscriber\Debugger;
use Symfony\Component\EventDispatcher\EventDispatcher;
$dispatcher = new EventDispatcher();
$eventNames = new EventNames();
$fileReader = new Reader();
$domLoader = new DomLoader();
$runner = new Runner(
$dispatcher,
$eventNames,
$canonicalProductDirPathname
);
$price = new Price();
$product = new Product();
$track = new Track();
$domMapper = new DomProductMapper($product, $track, $price);
$repository = new ProductRepository();
$unserializer = new Unserializer(
$fileReader,
$domLoader,
$domMapper
);
$populator = new Populator(
$dispatcher,
$eventNames,
$unserializer,
$repository
);
$populator->activate();
$runner->run();
foreach ($repository->getAll() as $product)
{
echo sprintf("%s\n", $product->getReleaseTitle());
foreach ($product->getTracks() as $track)
{
echo sprintf(">> %s\n", $track->getTitle());
}
}
use GuzzleHttp\Client;
use Kompakt\B3d\Details\Endpoint\Resource\Stock\Endpoint as StockEndpoint;
use Kompakt\B3d\Details\Endpoint\Cache\PhpFile\Serializer as PhpFileSerializer;
use Kompakt\B3d\Util\File\Writer;
use Symfony\Component\Stopwatch\Stopwatch;
$stockEndpoint = new StockEndpoint(
new Client(),
'<stock-endpoint-url>',
'<api-key>'
);
$stockEndpoint->fetch(['uuid-1', 'uuid-2']);
use GuzzleHttp\Client;
use Kompakt\B3d\Details\Endpoint\Resource\Order\Endpoint;
$orderEndpoint = new Endpoint(
new Client(),
'<stock-endpoint-url>',
'<api-key>'
);
$orderData = [
...
];
$itemData = [
...
];
$orderEndpoint->create($orderData, $itemData);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.