在Laravel 4上安装FPDF [英] Install FPDF on Laravel 4
问题描述
我没有设法在laravel 4上安装FPDF. 你能帮助我吗? 你能一步一步解释怎么做吗?
I didn't manage to install FPDF on laravel 4. Can you help me? Can you explain how to do it step by step?
我添加composer.json
"require": {
"illuminate/support": "4.0.x"
},
"require-dev": {
"anouar/fpdf": "dev-master"
},
在此之后,在shell上,我使用composer更新.现在呢?
after this, on shell, I use composer update. And now?
推荐答案
在您的composer.json文件中,添加:
To your composer.json file, add:
"require-dev": {
"anouar/fpdf": "dev-master"
}
然后更新您的Laravel项目,
Then update your Laravel project,
composer update
如果尚未安装laravel框架,请使用
If not already installed laravel framework use,
composer install
然后转到app/config/app.php并添加provider数组,
Then go to app/config/app.php and to the providers array add,
'Anouar\Fpdf\FpdfServiceProvider',
现在看起来像
'providers' => array(
// ...
'Anouar\Fpdf\FpdfServiceProvider',
)
最后,在别名数组中将别名添加到app/config/app.php中.
Finally, add the alias to app/config/app.php, within the aliases array.
'aliases' => array(
// ...
'Fpdf' => 'Anouar\Fpdf\Facades\Fpdf',
)
现在您可以在任何地方使用Fpdf
,
Now you can use Fpdf
anywhere like,
在app/routes.php中
In app/routes.php
Route::get('pdf', function(){
Fpdf::AddPage();
Fpdf::SetFont('Arial','B',16);
Fpdf::Cell(40,10,'Hello World!');
Fpdf::Output();
exit;
});
然后使用您的网址进行测试,
Then test it with your url like,
http://localhost/laravel/pdf
您可以看到Packagist https://packagist.org/packages/anouar/fpdf
You can see the Packagist https://packagist.org/packages/anouar/fpdf
此处还有GitHub Repo https://github.com/xroot/laravel-fpdf
And the GitHub Repo here https://github.com/xroot/laravel-fpdf
这篇关于在Laravel 4上安装FPDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!