Joomla and DOMPDF integration errors - joomla

I'm trying to integrate DOMPDF to our Joomla (Version 1.5.24) project and I keep getting these errors:
Strict standards: Non-static method JLoader::load() should not be called statically in C:\xampp\htdocs\proj\libraries\loader.php on line 162
Strict standards: Non-static method JLoader::register() should not be called statically in C:\xampp\htdocs\proj\libraries\loader.php on line 139
Fatal error: Class 'DOMPDF' not found in C:\xampp\htdocs\proj\components\com_reports\views\details\view.pdf.php on line 23
Strict standards: Non-static method JFactory::getDBO() should not be called statically, assuming $this from incompatible context in C:\xampp\htdocs\oasis\libraries\joomla\session\storage\database.php on line 84
Strict standards: Non-static method JTable::getInstance() should not be called statically, assuming $this from incompatible context in C:\xampp\htdocs\oasis\libraries\joomla\session\storage\database.php on line 89
Strict standards: Non-static method JFactory::getDBO() should not be called statically, assuming $this from incompatible context in C:\xampp\htdocs\oasis\libraries\joomla\database\table.php on line 112
The function that instantiates the DOMPDF object is located in one of the views of the component:
class ReportsViewDetails extends JView{
function display($tpl = null){
global $mainframe;
//echo "hello";
$this->generatePDF();
}
function generatePDF(){
require_once("./components/com_reports/helper/dompdf/dompdf_config.inc.php");
$html =
'<html><body>'.
'<p>Put your html here, or generate it with your favourite '.
'templating system.</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
}
}
It sees the file that is required but dompdf_config.inc.php outputs errors described above. I'm not sure what is causing this since the file only contains define lines and an autoload function. The content of the file can be seen here: http://code.google.com/p/dompdf/source/browse/trunk/dompdf/dompdf_config.inc.php.
Please help! Thanks!

all those strict standard warnings you are getting is becuase of this line
error_reporting(E_STRICT | E_ALL);
in dompdf_config.inc.php
and you should include dompdf/include/dompdf.cls.php

Related

PHP Laminas PHPStan - Call to an undefined method Laminas\Stdlib\RequestInterface::isPost()

We are running phpstan on a laminas project and running into errors.
As an example, in the controller we have some standard code which works fine.
$request = $this->getRequest();
if ($request->isPost()) { ... }
However phpstan is complaining:
Call to an undefined method Laminas\Stdlib\RequestInterface::isPost()
The problem appears that getRequest() is actually returning an instance of Laminas\Http\PhpEnvironment\Request which does inherit the isPost function from Laminas\Http\Request. But this function is not defined in RequestInterface.
One solution would be to define isPost in RequestInterface although I would prefer to avoid changes to the vendor code.
Is there a better way of getting round this?

How to fix null given error in laravel-dump-server?

I added "beyondcode/laravel-dump-server": "^1.2"
to my Laravel 5.7 application and sometimes I got error
[2018-10-18 03:44:02] local.ERROR: Argument 1 passed to Symfony\Component\VarDumper\Dumper\HtmlDumper::dump() must be an instance of Symfony\Component\VarDumper\Cloner\Data, null given, called in /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php on line 47 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 1 passed to Symfony\\Component\\VarDumper\\Dumper\\HtmlDumper::dump() must be an instance of Symfony\\Component\\VarDumper\\Cloner\\Data, null given, called in /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php on line 47 at /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/symfony/var-dumper/Dumper/HtmlDumper.php:111)
[stacktrace]
I run server in my console as :
php artisan dump-server --format=html > public/dump.html
I added wrapper method to commom trait of my app:
<?php
namespace App\Http\Traits;
use File;
use Barryvdh\Debugbar\Facade as Debugbar;
use Carbon\Carbon;
use Config;
use Intervention\Image\Facades\Image as Image;
trait funcsTrait
{
public function d($data)
{
if (empty($data)) {
return;
}
dump($data);
}
and calling this method in my control :
$this->d('ProfilePageTest Test51:: $newUserSessionData::' . print_r($newUserSessionData, true));
And sometimes I got error described above.
In my wrapper I tried to exclude calling of dump with empty value, supposing that empty value could be reason of this error ?
But looks like the reason was different. If there is a way make work it properly?
Thanks!

Having trouble with Model Bind - Laravel Breadcrumbs

Having trouble with Model Bind on davejamesmiller/laravel-breadcrumbs.
I'll try to be brief, but if you need more data just ask =D
This is my controller/action signature:
public function edit(Request $request, Vertical $vertical, UserMacro $macro)
And this is my BC for the corresponding route:
Breadcrumbs::register('macro-edit', function (Generator $breadcrumbs, $vertical, $macro) {
$breadcrumbs->parent('macro-index');
$breadcrumbs->push($macro->name, route('macro-edit', [$vertical->_id, $macro]));
});
I'm getting the string ID on $vertical and $macro, breaking on $macro->name. If I add Hints as the action have I get aType error.
Trying to get property of non-object (View: /.../resources/views/layouts/app.blade.php) (View: /.../resources/views/layouts/app.blade.php)
Type error: Argument 2 passed to DaveJamesMiller\Breadcrumbs\BreadcrumbsServiceProvider::{closure}() must be an instance of App\Vertical, string given, called in /.../vendor/davejamesmiller/laravel-breadcrumbs/src/BreadcrumbsGenerator.php on line 68 (View: /.../resources/views/layouts/app.blade.php) (View: /.../resources/views/layouts/app.blade.php)
I didn't analyze core code of library, so i don't know why controllers work, but breadcrumbs don't. Recipe to working model binding is use proper route naming convention.
Breadcrumbs::for('messages.show', function($trail, \App\Models\MassMessage $massMessage) {
$trail->parent('Index');
$trail->push('Show', route('messages.show', $massMessage));
});
Route::get('messages/{massMessage}', 'MessageController#show')->name('messages.show');
// error (controllers are fine)
Route::get('mass-mmessages/{massMessage}', 'MessageController#show')->name('messages.show');
// works both
The same problem is with resource route.
edit:
I was wrong. Controller also doesn't work. It not raise error but it pass empty Eloquent object. In my case i needed to change $massMessage variable's name into $message in both places and works fine, now.

Using facade in Models issue

I am developing a project on Laravel 5.2 , i may use facades (Auth,Request,Cache.. ) in controllers but not in any model.
this is the error:
FatalErrorException in Post.php line 73:
syntax error, unexpected '(', expecting ',' or ';'
and this is line 73:
protected $user = \Auth::user();
You cannot set a class property's default value like that. Below you can find an excerpt taken from the PHP: Properties Documentation:
This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated.
Since Auth::user() depends on run-time information stored in the session for its value to be returned, your definition is invalid. To overcome that you can set the default value in the constructor like so:
protected $user;
public function __construct()
{
$this->user = \Auth::user();
}

Fatal error: Cannot redeclare class JInput in JOOMLA

Today i just started my first joomla extension. I am using lendr sample joomla3.1 extnsion as a reference
$app = JFactory::getApplication()->input;
$controller = $app->input->get('controller','default');
i got following error on line execution of 2
Fatal error: Cannot redeclare class JInput in C:\Users\arslan\Desktop\xampp-win32-1.8.1-VC9\xampp\htdocs\COM\libraries\joomla\input\input.php on line 34
and line 34 of input.php is just implementation of interface
*/
class JInput implements Serializable, Countable
{
any idea about this error.

Resources