Lançado Adianti Framework 7.6!
Clique aqui para saber mais
erro não acha mais as classes do adianti boa noite, to testando relatórios feitos no Jasper Repoerter exemplo do nosso amigo Armando Ribeiro, está funcionando perfeito, só que apos eu usar a classe PHJasper parece que não acha mais as classes do adianti, neste exemplo abaixo tento fazer um new TMessage e fala que a classe TMessage não existe. $jasper = new PHPJasperPHPJasper; $jasper->process($input,$output,$...
RS
erro não acha mais as classes do adianti  
boa noite, to testando relatórios feitos no Jasper Repoerter exemplo do nosso amigo Armando Ribeiro, está funcionando perfeito, só que apos eu usar a classe PHJasper parece que não acha mais as classes do adianti, neste exemplo abaixo tento fazer um new TMessage e fala que a classe TMessage não existe.

$jasper = new PHPJasper\PHPJasper; $jasper->process($input,$output,$options)->execute(); new TMessage('info', 'Relatório Processado');


Erro que retorna:

Fatal error: Uncaught Error: Class 'TMessage' not found in C:wamp64wwwsgoappcontrolsgolistsProfissionalList.class.php on line 353


Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (7)


NR

Você está usando namespace?
RS

bom dia Nataniel, creio que sim, esta classe PHPJasper deve usar.
RS

Classe PHPJasper

  1. <?php
  2. /*
  3.  * This file is part of the PHPJasper.
  4.  *
  5.  * (c) Daniel Rodrigues (geekcom)
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace PHPJasper;
  12. class PHPJasper
  13. {
  14.     /**
  15.      * @var string
  16.      */
  17.     protected $command;
  18.     /**
  19.      * @var string
  20.      */
  21.     protected $executable;
  22.     /**
  23.      * @var string
  24.      */
  25.     protected $pathExecutable;
  26.     /**
  27.      * @var bool
  28.      */
  29.     protected $windows;
  30.     /**
  31.      * @var array
  32.      */
  33.     protected $formats = ['pdf''rtf''xls''xlsx''docx''odt''ods''pptx''csv''html''xhtml''xml''jrprint'];
  34.     /**
  35.      * PHPJasper constructor
  36.      */
  37.     public function __construct()
  38.     {
  39.         $this->executable 'jasperstarter';
  40.         $this->pathExecutable __DIR__ '/../bin/jasperstarter/bin';
  41.         $this->windows strtoupper(substr(PHP_OS03)) === 'WIN' true false;
  42.     }
  43.     /**
  44.      * @return string
  45.      */
  46.     private function checkServer()
  47.     {
  48.         return $this->command $this->windows $this->executable './' $this->executable;
  49.     }
  50.     /**
  51.      * @param string $input
  52.      * @param string $output optional
  53.      * @return $this
  54.      * @throws Exception\InvalidInputFile
  55.      */
  56.     public function compile(string $inputstring $output '')
  57.     {
  58.         if (!is_file($input)) {
  59.             throw new \PHPJasper\Exception\InvalidInputFile();
  60.         }
  61.         $this->command $this->checkServer();
  62.         $this->command .= ' compile ';
  63.         $this->command .= '"' realpath($input) . '"';
  64.         if (!empty($output)) {
  65.             $this->command .= ' -o ' "\"$output\"";
  66.         }
  67.         return $this;
  68.     }
  69.     /**
  70.      * @param string $input
  71.      * @param string $output
  72.      * @param array $options
  73.      * @return $this
  74.      * @throws Exception\InvalidInputFile
  75.      * @throws Exception\InvalidFormat
  76.      */
  77.      
  78.     public function process(string $inputstring $output, array $options = [])
  79.     {
  80.         $options $this->parseProcessOptions($options);
  81.         if (!$input) {
  82.             throw new \PHPJasper\Exception\InvalidInputFile();
  83.         }
  84.         $this->validateFormat($options['format']);
  85.         $this->command $this->checkServer();
  86.         if ($options['locale']) {
  87.             $this->command .= " --locale {$options['locale']}";
  88.         }
  89.         $this->command .= ' process ';
  90.         $this->command .= "\"$input\"";
  91.         $this->command .= ' -o ' "\"$output\"";
  92.         $this->command .= ' -f ' join(' '$options['format']);
  93.         if ($options['params']) {
  94.             $this->command .= ' -P ';
  95.             foreach ($options['params'] as $key => $value) {
  96.                 $this->command .= " " $key '="' $value '" ' " ";
  97.             }
  98.         }
  99.         if ($options['db_connection']) {
  100.             $mapDbParams = [
  101.                 'driver' => '-t',
  102.                 'username' => '-u',
  103.                 'password' => '-p',
  104.                 'host' => '-H',
  105.                 'database' => '-n',
  106.                 'port' => '--db-port',
  107.                 'jdbc_driver' => '--db-driver',
  108.                 'jdbc_url' => '--db-url',
  109.                 'jdbc_dir' => '--jdbc-dir',
  110.                 'db_sid' => '-db-sid',
  111.                 'xml_xpath' => '--xml-xpath',
  112.                 'data_file' => '--data-file',
  113.                 'json_query' => '--json-query'
  114.             ];
  115.             foreach ($options['db_connection'] as $key => $value) {
  116.                 $this->command .= {$mapDbParams[$key]} {$value}";
  117.             }
  118.         }
  119.         if ($options['resources']) {
  120.             $this->command .= " -r {$options['resources']}";
  121.         }
  122.         return $this;
  123.     }
  124.     /**
  125.      * @param array $options
  126.      * @return array
  127.      */
  128.     protected function parseProcessOptions(array $options)
  129.     {
  130.         $defaultOptions = [
  131.             'format' => ['pdf'],
  132.             'params' => [],
  133.             'resources' => false,
  134.             'locale' => false,
  135.             'db_connection' => []
  136.         ];
  137.         return array_merge($defaultOptions$options);
  138.     }
  139.     /**
  140.      * @param $format
  141.      * @throws Exception\InvalidFormat
  142.      */
  143.     protected function validateFormat($format)
  144.     {
  145.         if (!is_array($format)) {
  146.             $format = [$format];
  147.         }
  148.         foreach ($format as $value) {
  149.             if (!in_array($value$this->formats)) {
  150.                 throw new \PHPJasper\Exception\InvalidFormat();
  151.             }
  152.         }
  153.     }
  154.     /**
  155.      * @param string $input
  156.      * @return $this
  157.      * @throws \Exception
  158.      */
  159.     public function listParameters(string $input)
  160.     {
  161.         if (!is_file($input)) {
  162.             throw new \PHPJasper\Exception\InvalidInputFile();
  163.         }
  164.         $this->command $this->checkServer();
  165.         $this->command .= ' list_parameters ';
  166.         $this->command .= '"'.realpath($input).'"';
  167.         return $this;
  168.     }
  169.     /**
  170.      * @param bool $user
  171.      * @return mixed
  172.      * @throws Exception\InvalidCommandExecutable
  173.      * @throws Exception\InvalidResourceDirectory
  174.      * @throws Exception\ErrorCommandExecutable
  175.      */
  176.     public function execute($user false)
  177.     {
  178.         $this->validateExecute();
  179.         $this->addUserToCommand($user);
  180.         $output = [];
  181.         $returnVar 0;
  182.         chdir($this->pathExecutable);
  183.         exec($this->command$output$returnVar);
  184.         if ($returnVar !== 0) {
  185.             throw new \PHPJasper\Exception\ErrorCommandExecutable();
  186.         }
  187.         return $output;
  188.     }
  189.     /**
  190.      * @return string
  191.      */
  192.     public function output()
  193.     {
  194.         return $this->command;
  195.     }
  196.     /**
  197.      * @param $user
  198.      */
  199.     protected function addUserToCommand($user)
  200.     {
  201.         if ($user && !$this->windows) {
  202.             $this->command 'su -u ' $user " -c \"" $this->command "\"";
  203.         }
  204.     }
  205.     /**
  206.      * @throws Exception\InvalidCommandExecutable
  207.      * @throws Exception\InvalidResourceDirectory
  208.      */
  209.     protected function validateExecute()
  210.     {
  211.         if (!$this->command) {
  212.             throw new \PHPJasper\Exception\InvalidCommandExecutable();
  213.         }
  214.         if (!is_dir($this->pathExecutable)) {
  215.             throw new \PHPJasper\Exception\InvalidResourceDirectory();
  216.         }
  217.     }
  218. }
  219. </code>
NR

Adicione o código abaixo na sua classe e veja se funciona:
  1. <?php
  2. use Adianti\Widget\Dialog\TMessage;
  3. ?>
RS

realmente o PHPJasper usa o namespace logo no inicio da classe tem

namespace PHPJasper;


use AdiantiWidgetDialogTMessage; é para colocar no PHPJasper? bom mas coloquei na classe onde chama o PHPJasper e no PHPJasper e deu erro

Parse error: syntax error, unexpected 'use' (T_USE) in
RS

Continuo com este problema, se alguem tiver alguna luz...obrigado
NR

https://pt.stackoverflow.com/questions/51014/erro-unexpected-use-t-use-ao-usar-autoload