Forum


Replies: 8   Views: 4785
Namespace version throws error
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Movian  · 10-06-2016 - 13:08

Hey,

 

trying to setup the namespace version of phpdocx 6.0 in laravel  and I am getting a warning about a depricated constructor in fpdi_pdf_parser.php
 

ErrorException in fpdi_pdf_parser.php line 22:
Methods with the same name as their class will not be constructors in a future version of PHP; fpdi_pdf_parser has a deprecated constructor


here is how I have setup the controler - am I doing something wrong? 

<?php
namespace App\Http\Controllers;

use Auth;
use Session;

use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;

class DocXController extends Controller {

    public function showMakeDoc()
    {
        require_once app_path().'\phpdocx\Classes\Phpdocx\Create\CreateDocx.inc';
        $docx = new CreateDocx();
        $docx->addText('This is a test');
        $docx->createDocx('../word_documents/hello_world');

        return Redirect::to(public_path().'/hello_world');
    }         
}

 

Posted by admin  · 10-06-2016 - 13:17

Hello,

We're going to check it and solve it; it's not an error but a deprecated message so the library works perfectly with all PHP versions, but as an external class used in the library to merge PDF files is using a constructor with the same class name a future PHP release (not currently available) may fail. PHP 7 added this 'deprecrated' message and it can be easily hidden in the PHP config or the framework setting the error level, but some frameworks show all messages by default when working in dev environments.

As workaround please edit the file Classes/Phpdocx/Create/CreateDocx.inc and in line 64 replace this:

error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);

by:

error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);

The deprecated message shouldn't appear anymore.

Regards.

Posted by Movian  · 10-06-2016 - 13:48

Thanks for the prompt reply,

 

adjusted the line you mentioned but still getting the error, will look further into my laravel development environment see if there is something overriding that.

 

Posted by Movian  · 10-06-2016 - 15:23

Ok I disabled the error but am still getting a problem


$docx = new Phpdocx\Create\CreateDocx();

Appears to be triggering the problem, the word doc does not get generated... 

 

Posted by admin  · 10-06-2016 - 16:16

Hello,

Please run one of the included examples standalone and using PHP CLI mode to test if the library is working on your server.

As you're using a framework, maybe you didn't include the autoloader of phpdocx to be able to use the library? Please check your server logs.

About this line:

$docx->createDocx('../word_documents/hello_world');

It seems very strange, because a relative path like this one in a framework is not the public folder, so maybe it's wrong or the web server can't write in the folder.

Regards.

Posted by Movian  · 10-06-2016 - 16:25

running add bookmark sample_1.php  from command line worked fine.

I am likely missing something crucial integrating the library into laravel as I have only recently started working with it. I will continue trouble shooting, thank you

Posted by admin  · 10-06-2016 - 16:32

Hello,

In the plugins folder of the namespace package you can find a quick guide to use phpdocx with any composer framework (such as symfony2, laravel...)

Regards.

Posted by Movian  · 10-06-2016 - 16:43

Thank you so much this was EXACTLY what I was missing.

Can I suggest adding a note regarding the location of the install guide text file to http://www.phpdocx.com/documentation/practical/creating-a-new-document 

As that is where I started looking after extracting the files to my development environment and asume others may start looking there too.

Thanks for the assistance, it's much apriciated :)

Posted by admin  · 10-06-2016 - 16:54

Hello,

Sure. We're going to add it following your suggestion.

On https://www.phpdocx.com/documentation/cookbook/ there're some articles about using phpdocx with Composer, Symfony, Laravel and others can be found.

Regards.