Laravel 4.2:将 PHP 文件(库)包含到控制器中 [英] Laravel 4.2: Include a PHP file (library) into controller

查看:23
本文介绍了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 文件(库)包含到控制器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆