lavela / phpjasper

Create Reports in PHP with JasperReports
MIT License
66 stars 20 forks source link

syntax error, unexpected '.', expecting ',' or ';' #7

Closed edukmattos closed 8 years ago

edukmattos commented 8 years ago

Hi !

When I run locally there are no problems but when I run the web server via cpanel (Godaddy), displays the error on line 8 below.

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) HELP syntax error, unexpected '.', expecting ',' or ';'

/home/spmtec/public_html/siscad.aafc/vendor/lavela/phpjasper/src/JasperPHP/JasperPHP.php

<?php namespace JasperPHP; class JasperPHP { protected $executable = "jasperstarter"; //executable jasperstarter

  1. protected $path_executable = DIR . '/../JasperStarter/bin/'; //Path to executable protected $the_command; protected $redirect_output;

Im using: PHP version localhost: 5.6.11 PHP version www: 5.5

edukmattos commented 8 years ago

Podemos conversar em português ?

edukmattos commented 8 years ago

corrigindo... existe dois "_" antes e depois do DIR pois nao aparecem quando envio.

  1. protected $path_executable = DIR . '/../JasperStarter/bin/'; //Path to executable
geekcom commented 8 years ago

Opa, então qual a dúvida?

edukmattos commented 8 years ago

Oi ! Surge o erro abaixo quando eu rodo no servidor compartilhado (GoDaddy). Quando rodo localmente, funciona beleza.

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) HELP syntax error, unexpected '.', expecting ',' or ';'

/home/spmtec/public_html/siscad.aafc/vendor/lavela/phpjasper/src/JasperPHP/JasperPHP.php

edukmattos commented 8 years ago

Oi ! Alguma sugestão da causa do erro ? Quando executo localmente, funciona beleza. Quando via web, não.

Será problema de versão do php ? PHP version localhost: 5.6.11 PHP version www: 5.5

lavela commented 8 years ago

Olá ecmattos, você pode me descrever em qual linha ocorre o erro no JasperPHP.php ?

edukmattos commented 8 years ago

8

jadsonbr commented 8 years ago

Na declaração deixe apenas assim

 protected $path_executable;

E no construtor coloque da seguinte maneira.

function __construct($resource_dir = false)
{
        $this->path_executable .= __DIR__ . '/../JasperStarter/bin/';
        //Restante do código   
}  
edukmattos commented 8 years ago

So para confirmar...

Mudo isto:

class JasperPHP { protected $executable = 'jasperstarter'; //executable jasperstarter protected $path_executable = DIR . '/../JasperStarter/bin/'; //Path to executable protected $the_command; protected $redirect_output; protected $background; protected $windows = false;

protected $formats = array('pdf', 'rtf', 'xls', 'xlsx', 'docx', 'odt', 'ods', 'pptx', 'csv', 'html', 'xhtml', 'xml', 'jrprint');
protected $resource_directory; //Path to report resource dir or jar file

function __construct($resource_dir = false)
{
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
       $this->windows = true;

    if (!$resource_dir) {
        $this->resource_directory = __DIR__ . '/../../../vendor/cossou/jasperphp/src/JasperStarter/bin';
    } else {
        if (!file_exists($resource_dir))
            throw new \Exception('Invalid resource directory.', 1);

        $this->resource_directory = $resource_dir;
    }
}

Para isto:

class JasperPHP { protected $executable = 'jasperstarter'; //executable jasperstarter protected $path_executable;<<<<<<<<<<<<<<<<<<<<<< protected $the_command; protected $redirect_output; protected $background; protected $windows = false;

protected $formats = array('pdf', 'rtf', 'xls', 'xlsx', 'docx', 'odt', 'ods', 'pptx', 'csv', 'html', 'xhtml', 'xml', 'jrprint');
protected $resource_directory; //Path to report resource dir or jar file

function __construct($resource_dir = false)
{
    $this->path_executable .= __DIR__ . '/../JasperStarter/bin/'; <<<<<<<<<<

    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
       $this->windows = true;

    if (!$resource_dir) {
        $this->resource_directory = __DIR__ . '/../../../vendor/cossou/jasperphp/src/JasperStarter/bin';
    } else {
        if (!file_exists($resource_dir))
            throw new \Exception('Invalid resource directory.', 1);

        $this->resource_directory = $resource_dir;
    }
}
jadsonbr commented 8 years ago

Isso mesmo ecmattos.