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

查看:102
本文介绍了Laravel 4.2:在控制器中包含一个PHP文件(库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Laravel 4.2做一个项目,我需要在控制器中包含一个PHP文件(一个将PDF转换为Text的库),然后返回带有文本的变量,知道怎么做吗?

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天全站免登陆