how dompdf supports php7 - dompdf

I used older version of dompdf in a project about 5 years ago. Now I just downloaded 0.8.0 (https://github.com/dompdf/dompdf/releaseslink) version, and its release note says "Improves compatibility with PHP 7.1". But for demo usage, it has php5.x "use" style as "use Dompdf\Dompdf;" that throw error on PHP 7. What is appropriate method to use dompdf on php7?

I changed those lines :
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
to :
$dompdf = new Dompdf\Dompdf();
and now, it works on php7.

Another way to solve this problem from dompdf if your php version is 7.0 and your dompdf_config.inc.php file is exists.
if(class_exists('DOMPDF', false))
{
return;
}
PHP_VERSION >= 7.0 or die("DOMPDF requires PHP 7.0+");
Just change 7.0 to 5.6
PHP_VERSION >= 5.6 or die("DOMPDF requires PHP 7.0+");
It works fine for me, I hope this helps someone.

Related

Call to undefined function factory()

Environment: Laravel Framework Lumen (8.2.2) (Laravel Components ^8.0)
When I run
$blogs = factory('App\Blog', 2)->create();
in BlogsControllerTest.php, it shows
Call to undefined function factory()
As Laravel's upgrade guide says the Model factory was changed.
The new way is like this App\Models\Blog::factory()->count(3)->create();
To use old version referrer to documentation.
However, to ease the upgrade process, a new laravel/legacy-factories package has been created to continue using your existing factories with Laravel 8.x
To install it use composer composer require laravel/legacy-factories
Answering my own question in case it helps somebody.
It works this way too.
$blogs = BlogFactory::new()->count(2)->create();
ref: laravel.com/docs/8.x/database-testing#connecting-factories-and-models

PHP / Laravel 8.0 : UI of link method on Paginator instance is broken after upgrading from version 7.25

I switched my laravel app from 7.25 to 8.0. Now I am facing pagination problem.
{{ $download->links() }}
in controller
$download = Download::paginate(2);
Yes, it is working well but the UI is broken now.
image error ui
In Laravel 8 more options were added how pagination can be displayed.
This instruction https://laravel.com/docs/8.x/pagination#using-bootstrap should help.
Go to App\Providers\AppServiceProvider
add
public function boot() { Paginator::useBootstrap(); }
and import
use Illuminate\Pagination\Paginator;
Seems like they have made changes to the UI (bootstrap) in the latest, version.
I would suggest you to create a custom UI for that links by yourself. Use the following commands to publish the pagination views to resource directory and make some changes accordingly.
php artisan vendor:publish --tag=laravel-pagination
and points to your custom view with the following line of code:
{{ $paginator->links('view.name') }}
which is in your case {{$download->links('view.name')}}

Need install Laravel-ide-helper for VS Code

I use VS Code, not use PHP Storm. Should I install 'laravel-ide-helper'?
You can require this package with composer using the following command:
composer require --dev barryvdh/laravel-ide-helper
Then if you are using Laravel versions older than 5.5, add the service provider to the providers array in config/app.php:
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class
In Laravel, instead of adding the service provider in the config/app.php file, you can add the following code to your app/Providers/AppServiceProvider.php file, within the register() method:
public function register(){
if ($this->app->environment() !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
// ...
}
This basically allow your application to load the Laravel IDE Helper on non-production environments.
It does help with code completion (automatically importing classes, showing methods, etc..). It works with VSCode the same as it does for PHPStorm as far as I can tell. The 'ide-helper-models' also appears to work the same. I'm unsure what the 'ide-helper:meta' does, but the docs only mention support for PHPStorm.

"Call to undefined function str_slug()" in Laravel 6.0

I've upgraded my laravel 5.8 project to 6.0. It has upgraded successfully but when I'm trying to run the project or installing another package to my project it is giving me error named as "Call to undefined function str_slug()" in session.php. I don't know why....
Call to undefined function str_slug()
If you have gone through the upgrade guide then you must know that
String and Array Helpers have been removed from Core Framework
So if if You need to still use the helper install the package
composer require laravel/helpers
and all the helpers are moved to this package
String and Array helpers are removed from laravel 6.0 Core Framework
https://laravel.com/docs/6.0/upgrade#helpers
So if You need to still use the helper install the package
composer require laravel/helpers
Or you can use by Laravel facade
use Illuminate\Support\Str;
$slug = Str::slug('Laravel 5 Framework', '-');
Personal I hard to do the following on Laravel 6
on the app Controllers add this use Illuminate\Support\Str; then
something like this 'slug' => Str::slug($request->title)
There are two options to resolve the issue of call to undefined function str_slug().
1.You should run the command composer require laravel/helpers
Or another option is when you don't want to install packages then this below solution is the easy way to solve your issue and it is the best way.
2.You can use facades class
use Illuminate\Support\Str;
public function index(Request $request)
{
$slug = Str::slug($request->name);
}
$post = Post::create([
'slug' => S t r::slug($request->title),
here we go
composer require laravel/helpers
php artisan optimize:clear

Laravel Error: Call to undefined method class::seeJsonStructure()

do i need to use some namespaces or something?
here's the code:
$response = $this->call('POST', 'admin/apps/list', []);
$this->seeJsonStructure([...]);
seeJsonStructure is not available until Laravel 5.2.
You need to upgrade the Laravel version to 5.2.
Since Laravel 5.4, it has been renamed to assertJsonStructure().

Resources