PHPJasper / phpjasper

A PHP report generator
MIT License
469 stars 162 forks source link

How to make it work on heroku server if on heroku cannot save files #262

Closed Kelvinnay closed 4 years ago

Kelvinnay commented 4 years ago

**

Your report has an error and couldn 't be processed!\ Try to output the command using the function output(); and run it manually in the console.

in PHPJasper.php line 250 at PHPJasper->execute()in reporteController.php line 461

** $reportName='\reporteAulas.jasper'; //try{ $input = $path . '\public\reportes'.$reportName;
$output = $path . '\public\reportes'; //is there a way to store directily to aws s3? $jasper = new PHPJasper; $options = [ 'format' =>['pdf'], 'locale' => 'es', 'params' => [], 'db_connection' => [ 'driver' => 'postgres', 'username' =>env('DB_USERNAME'), 'password' =>'"'.env('DB_PASSWORD').'"', 'host' => env('DB_HOST'), 'database' =>env('DB_DATABASE'), 'port' => env('DB_PORT'), ] ]; $jasper->process( $input, $output, $options )->execute();


On my local PC is working but when is deployed to heroku, doesnt allowed me to write files in its filesystems due to ->execute(); save files on directory. is there a way to create just a PDF as an stream rather than save it on a local directory? or it is a way to execute it directly on aws s3 ?

here is my enviroments vars on heroku I have already install java image

here is the java version image

Kelvinnay commented 4 years ago

I solve the problem the only issue was url of the folder on heroku. I typed "/app/public/your_folder" rather than "/../app/public/your_folder" on $input and $output vars. now code.. $jasper->process( $input, $output, $options )->execute();

is working fine. I spend time to get the solution. but I did it at the beggining I was wondering if java was the problem but is not just remember to install the buildpack of java on heroku and add file with name "system.properties" and add inside the file this "java.runtime.version=1.8.0_202 maven.version=3.6.2" in order to get java installed with laravel on heroku. when deployin on your cli will look like this.

../your_proyect>git push heroku master Enumerating objects: 11, done. Counting objects: 100% (11/11), done. Delta compression using up to 4 threads Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 778 bytes | 389.00 KiB/s, done. Total 6 (delta 4), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> JVM Common app detected ///here is java detected remote: -----> Installing JDK 1.8.0_202... done remote: -----> PHP app detected remote: -----> Bootstrapping... remote: -----> Installing platform packages... remote: - php (7.4.9) remote: - ext-mbstring (bundled with php) remote: - apache (2.4.46) remote: - nginx (1.18.0) remote: -----> Installing dependencies... remote: Composer version 1.10.10 2020-08-03 1

remember that heroku dynos delete files created daily or when restart or deploy on their dynos is recommended to use external cloud service storage like aws s3. but you can store it temporally for testing as I did.