PHP code example of mathielen / import-engine-bundle
1. Go to this page and download the library: Download mathielen/import-engine-bundle 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/ */
mathielen / import-engine-bundle example snippets
public function registerBundles()
{
return array(
...
new Mathielen\ImportEngineBundle\MathielenImportEngineBundle(),
...
);
}
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
/**
* Import a given file, that was POST'ed to the HTTP-Endpoint /app/import
* * Using the default sorage provider
* * The importer is auto-discovered with the format of the file
*
* @Route("/app/import", name="homepage")
* @Method("POST")
*/
public function importAction(\Symfony\Component\HttpFoundation\Request $request)
{
//create the request for the import-engine
$importRequest = new \Mathielen\ImportEngine\ValueObject\ImportRequest($request->files->getIterator()->current());
/** @var \Mathielen\ImportEngine\Import\ImportBuilder $importBuilder */
$importBuilder = $this->container->get('mathielen_importengine.import.builder');
$import = $importBuilder->build($importRequest);
/** @var \Mathielen\ImportEngine\Import\Run\ImportRunner $importRunner */
$importRunner = $this->container->get('mathielen_importengine.import.runner');
$importRun = $importRunner->run($import);
return $this->render('default/import.html.twig', $importRun->getStatistics());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.