我想将外部库添加到我的 symfony 2 项目中。我用的是2.4版本。我已经阅读了很多“如何做”,但所有解决方案都不适用于此版本。
你能告诉我如何在我的项目中添加我的类(class)吗?
我的类(class) Html2Pdf:
<?php
class Html2Pdf
{
// Code ...
}
?>
最佳答案
您了解服务吗?
如果您想在 Controller 中使用 YoutubeDownloader 类,则必须将其定义为服务,以便您可以在任何地方调用。
打开你的 services.yml;
YourBundle/Resources/config/services.yml
parameters:
youtubeDownload: YourBundle/YourPathToClass
services:
bundlename.controllername.controller:
class: "%youtubeDownload%"
更多信息: http://symfony.com/doc/current/cookbook/controller/service.html
关于php - Symfony 2.4 如何加载外部类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20923244/