PHP code example of a.ambrogini / phpjasper

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

    

a.ambrogini / phpjasper example snippets




namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use PHPJasper\PHPJasper;

class DefaultController extends Controller {

    /**
     * @Route("/", name="default")
     */
    public function indexAction(Request $request) {
        $input = '/src/SymfonyProject/vendor/a.ambrogini/phpjasper/examples/hello_world.jrxml';   

        $output = '/src/SymfonyProject/vendor/a.ambrogini/phpjasper/examples';    
        $options = [ 
            'format' => ['pdf', 'rtf'] 
        ];

        $jasper = new PHPJasper;

        $jasper->process(
            $input,
            $output,
            $options
        )->execute();
        
        return $this->render('default/index.html.twig');
    }

}