在哪里设置require once include in laravel?

Where to set require once include in laravel?

我的要求是将 braintree 包含到我的 laravel 应用程序中。第一步我将整个 sdk 复制到我的 laravel 应用程序文件夹中,该文件夹名为 braintree-php。接下来我进入我的 C:\xampp\htdocs\cserver\resources\views\layouts,下面的 app.blade.php 是我的代码的一部分。

<!DOCTYPE html>
@section('includebt')

@show
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>My system @yield ('role-heading')</title>

然后我有我的实际 blade 页面,我从上面的应用程序扩展 layout.This 只是代码的一部分,下面有更多详细信息,但我的重点是库包含。

@extends('layouts.app')


@section('includebt')
include(app_path().'/braintree-php/lib/Braintree.php');
Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('**');
Braintree_Configuration::publicKey('***');
Braintree_Configuration::privateKey('***');

@endsection

我收到这个错误 Class 'Braintree\ClientToken' not found (View:

你应该像这样通过作曲家来做

打开composer.json文件 只有一个要求 成功

"require": { 
"laravel/framework": "5.0.*", 
"illuminate/html": "^5.0", 
"braintree/braintree_php" : "3.20.0" 
},

并使用来自 artisian

的作曲家更新

之后您需要设置您的环境并生成客户端令牌并遵循 documentation . you may also think to go packagist .