LARAVEL Laravel 5 的 DOMPDF 包装器
LARAVEL DOMPDF Wrapper for Laravel 5
我执行了以下步骤但出现错误
步骤 1
插入 en composer.json
"barryvdh/laravel-dompdf": "0.6.*"
第2步
安装
php composer update
第 3 步
添加config/app.php
'providers' => [....
Barryvdh\DomPDF\ServiceProvider::class,
'aliases' => [....
'PDF' => Barryvdh\DomPDF\Facade::class,
步骤 4
routes.php
Route::resource('pdf', 'PdfController');
第 5 步从 php artisan make:controller PhpController
创建控制器
插入代码:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class PdfController extends Controller
{
public function Index() {
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream();
}}
第 5 步错误
呼叫urllocalhost/public/pdf
FatalThrowableError in PdfController.php line 16:
Fatal error: Class 'App\Http\Controllers\App' not found
第 22 行....
$pdf = App::make('dompdf.wrapper');
谢谢!征求意见。
您忘记为 App
命名空间添加前缀 \
。调用该函数的正确方法如下:
$pdf = \App::make('dompdf.wrapper');
您将必须使用 App Facade
use Illuminate\Support\Facades\App;
尝试使用此代码
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App;
我执行了以下步骤但出现错误
步骤 1
插入 en composer.json
"barryvdh/laravel-dompdf": "0.6.*"
第2步 安装
php composer update
第 3 步
添加config/app.php
'providers' => [....
Barryvdh\DomPDF\ServiceProvider::class,
'aliases' => [....
'PDF' => Barryvdh\DomPDF\Facade::class,
步骤 4
routes.php
Route::resource('pdf', 'PdfController');
第 5 步从 php artisan make:controller PhpController
创建控制器插入代码:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class PdfController extends Controller
{
public function Index() {
$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream();
}}
第 5 步错误
呼叫urllocalhost/public/pdf
FatalThrowableError in PdfController.php line 16:
Fatal error: Class 'App\Http\Controllers\App' not found
第 22 行....
$pdf = App::make('dompdf.wrapper');
谢谢!征求意见。
您忘记为 App
命名空间添加前缀 \
。调用该函数的正确方法如下:
$pdf = \App::make('dompdf.wrapper');
您将必须使用 App Facade
use Illuminate\Support\Facades\App;
尝试使用此代码
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App;