在 Laravel 4 上安装 FPDF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19319198/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install FPDF on Laravel 4
提问by chianta
I didn't manage to install FPDF on laravel 4. Can you help me? Can you explain how to do it step by step?
我没能在 Laravel 4 上安装 FPDF。你能帮我吗?你能解释一下如何一步一步地做到这一点吗?
I add on composer.json
我补充 composer.json
"require": {
"illuminate/support": "4.0.x"
},
"require-dev": {
"anouar/fpdf": "dev-master"
},
after this, on shell, I use composer update. And now?
在此之后,在 shell 上,我使用 composer update。现在?
回答by devo
To your composer.json file, add:
在 composer.json 文件中添加:
"require-dev": {
"anouar/fpdf": "dev-master"
}
Then update your Laravel project,
然后更新你的 Laravel 项目,
composer update
If not already installed laravel framework use,
如果还没有安装laravel框架使用,
composer install
Then go to app/config/app.php and to the providers array add,
然后转到 app/config/app.php 并添加到 providers 数组,
'Anouar\Fpdf\FpdfServiceProvider',
Now it's look like,
现在的样子,
'providers' => array(
// ...
'Anouar\Fpdf\FpdfServiceProvider',
)
Finally, add the alias to app/config/app.php, within the aliases array.
最后,将别名添加到 app/config/app.php 中的 aliases 数组中。
'aliases' => array(
// ...
'Fpdf' => 'Anouar\Fpdf\Facades\Fpdf',
)
Now you can use Fpdf
anywhere like,
现在你可以Fpdf
在任何地方使用,
In app/routes.php
在 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
You can see the Packagist https://packagist.org/packages/anouar/fpdf
你可以看到 Packagist https://packagist.org/packages/anouar/fpdf
And the GitHub Repo here https://github.com/xroot/laravel-fpdf
还有这里的 GitHub Repo https://github.com/xroot/laravel-fpdf
回答by broklyn gagah
the fpdf is external component and you must create a workbench to integrating this to laravel. this is smiliar [tutorial]http://jasonlewis.me/article/laravel-4-develop-packages-using-the-workbench
fpdf 是外部组件,您必须创建一个工作台以将其集成到 Laravel。这是 smiliar [教程] http://jasonlewis.me/article/laravel-4-develop-packages-using-the-workbench
or you can use other component. [dompdf]http://packalyst.com/packages/package/barryvdh/laravel-dompdf
或者您可以使用其他组件。[dompdf] http://packalyst.com/packages/package/barryvdh/laravel-dompdf