How to import FPDF content into Zend2?

0

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

The problem is that I do not know how to import.

The error is this:

Warning: require (/php/system_real/public/advice/fpdf/fpdf.php) [function.require]: failed to open stream: No such file or directory in C: \ xampp \ htdocs \ php \ application \ views \ scripts \ orcamento \ print.phtml on line 4

Fatal error: require () [function.require]: Failed opening required '/php/real_system/public/adds/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 \ real-system \ application \ views \ scripts \ orcamento \ print .phtml on line 4

The code snippet that requires require:

<?php

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

Here is the Controller excerpt:

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

  }
    
asked by anonymous 10.04.2017 / 16:59

1 answer

0

Solution with Zend itself

After editing I noticed that I was loading fpdf by Zend even so I can use it like this:

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

If it fails, do so:

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

But I really do not think it's a good idea to leave libs and things like that within public

Quick solution (before editing the question):

Your require should look like this:

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

What does it look for: 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 is not based on Apache, but on the system itself, however, it is possible to configure php.ini for this , but it's something I do not think necessary.

Just make the adjustment to something like:

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

Or create a global.php file as I explained in: link

You can also think about using spl and namespaces to base your load on this (or composer):

10.04.2017 / 18:45