How to import FPDF content to Zend2?

Asked

Viewed 154 times

0

I’m creating a budget page with Zend 2, to print with FPDF.

The problem is I don’t know how to import.

That is the mistake:

Warning: require(/php/sistema_real/public/aditivos/fpdf/fpdf.php) [Function.require]: failed to open stream: No such file or directory in C: xampp htdocs php sistema_real application views scripts orcamento imprimir.phtml on line 4

Fatal error: require() [Function.require]: Failed Opening required '/php/system_real/public/additives/fpdf/fpdf.php' (include_path='C: xampp htdocs php system_real application/./library;C: xampp htdocs php system_real library;.; xampp php PEAR') in C: xampp htdocs php sistema_real application views scripts orcamento print.phtml on line 4

inserir a descrição da imagem aqui

The chunk of the code that does require:

<?php

$end = $this->baseUrl('aditivos/fpdf/');
require($end.'fpdf.php');

Here the excerpt from the Controller:

public function imprimirAction()
  {
  $this->_helper->layout->disableLayout();

  }
  • No such file or directory ~ "no file or folder exists", summarizing the fpdf.php file does not exist in the folder, or the fpdf folder is not inside the additive folder, it is also possible that the additive folder is missing some letter or more.

  • But the address is right... the document is there: C: xampp htdocs php system_real public aditivos fpdf

  • and fpdf.php is there?

  • Yes yes, I’ve checked several times hehe

  • <?php $end = $this->baseUrl('additives/fpdf/'); require($end. 'fpdf.php');

  • It is to edit the question -.- ... Put the relevant code, I do not know what this is baseUrl friend. As far as I know this is not native to PHP, I am waiting.

  • Yes, this baseUrl is from Zendframework 2

  • I updated the answer, I didn’t know about the APPLICATION_PATH, see if this makes it easier.

  • Thank you very Much Guilherme! It’s working here with the solution before the edition, I’m already going to test the other.

Show 4 more comments

1 answer

0


Solution with own Zend

After editing I noticed that I was loading fpdf by Zend even then can use so:

<?php
require_once APPLICATION_PATH . '/aditivos/fpdf/fpdf.php';

If you fail do so:

<?php
require_once APPLICATION_PATH . '/public/aditivos/fpdf/fpdf.php';

But really I don’t think it’s a good idea to leave the libs and stuff like that inside the public


Quick fix (before editing the question):

Your require must be like this:

require '/php/sistema_real/public/aditivos/fpdf/fpdf.php';

What makes him look for it: c:/php/sistema_real/public/aditivos/fpdf/fpdf.php and not this: c:/xampp/htdocs/php/sistema_real/public/aditivos/fpdf/fpdf.php, because the PHP base by default is not based on Apache but on the system itself, however it is possible to configure php.ini for this, but it is something that I do not think necessary.

Just make the adjustment for something like:

require 'c:/xampp/htdocs/php/sistema_real/public/aditivos/fpdf/fpdf.php';

Or create a global.php file as I explained in: /a/195566/3635

You can also think about using spl and namespaces to base your upload on this (or by Composer):

Browser other questions tagged

You are not signed in. Login or sign up in order to post.