Laravel 4.2: Include a PHP file (library) into controller(Laravel 4.2:将 PHP 文件(库)包含到控制器中)
问题描述
我正在使用 Laravel 4.2 做一个项目,我需要在控制器中包含一个 PHP 文件(一个将 PDF 转换为文本的库),然后返回一个带有文本的变量,知道怎么做吗?
I'm doing a project using Laravel 4.2 where I need to include a PHP file (a library to transform a PDF into Text) into the controller, and then return a variable with the text, any idea how?
这是我的控制器:
public function transform() {
include ('includes/vendor/autoload.php');
}
还有我的 /app/start/global.php 文件:
ClassLoader::addDirectories(array(
app_path().'/commands',
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/includes',
));
这是错误:
include(includes/vendor/autoload.php): failed to open stream: No such file or directory
推荐答案
我认为你是对的兄弟,但是,我找到了另一种方法,也许不是正确的方法,但它有效.
I think you're right bro, but, i find another way, maybe not the right way, but it works.
就是这样,我创建了一个名为 Includes 的新文件夹并将我的文件放在那里,然后在/app/start/global.php 中添加了这一行:
Is like this, I created a new folder called Includes and put my files in there, then in the /app/start/global.php i added this line:
require app_path().'/includes/vendor/autoload.php';
现在正在工作:D
这篇关于Laravel 4.2:将 PHP 文件(库)包含到控制器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel 4.2:将 PHP 文件(库)包含到控制器中
基础教程推荐
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
