Skip to content

Commit c43f958

Browse files
committed
Add directory structure
1 parent 86e5947 commit c43f958

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ An example Braintree integration for PHP.
1414
3. Copy the `example.env` file to `.env` and fill in your Braintree API credentials. Credentials can be found by navigating to Account > My user > View API Keys in the Braintree control panel. Full instructions can be [found on our support site](https://articles.braintreepayments.com/control-panel/important-gateway-credentials#api-credentials).
1515

1616
4. Start the internal PHP server on port 3000
17-
`php -S localhost:3000`
17+
`php -S localhost:3000 -t public_html`
1818

1919
## Running Tests
2020

2121
All tests are integration tests. Integration tests make api calls to Braintree and require that you set up your Braintree credentials. You can run this project's integration tests by adding your sandbox api credentials to `.env` and running `./vendor/bin/phpunit --testsuite integration` on the command line.
2222

2323
## Pro Tips
2424

25-
* Run `php -S 0.0.0.0:3000` when launching the internal PHP server to listen on all interfaces on port 3000.
25+
* Run `php -S 0.0.0.0:3000 -t public_html` when launching the internal PHP server to listen on all interfaces on port 3000.
2626

2727
## Disclaimer
2828

braintree_init.php includes/braintree_init.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
session_start();
3-
require_once("vendor/autoload.php");
3+
require_once("../vendor/autoload.php");
44

5-
$dotenv = new Dotenv\Dotenv(__DIR__);
5+
$dotenv = new Dotenv\Dotenv(__DIR__ . "/../");
66
$dotenv->load();
77

88
Braintree\Configuration::environment(getenv('BT_ENVIRONMENT'));

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<php>
99
<const name="WEB_SERVER_HOST" value="localhost" />
1010
<const name="WEB_SERVER_PORT" value="3000" />
11-
<const name="WEB_SERVER_DOCROOT" value="." />
11+
<const name="WEB_SERVER_DOCROOT" value="./public_html" />
1212
</php>
1313
</phpunit>

checkout.php public_html/checkout.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once("braintree_init.php");
2+
require_once("../includes/braintree_init.php");
33

44
$amount = $_POST["amount"];
55
$nonce = $_POST["payment_method_nonce"];

index.php public_html/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php require_once("braintree_init.php"); ?>
1+
<?php require_once("../includes/braintree_init.php"); ?>
22

33
<html>
44
<head>

transaction.php public_html/transaction.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
require_once("braintree_init.php");
2+
require_once("../includes/braintree_init.php");
33
if (isset($_GET["id"])) {
44
$transaction = Braintree\Transaction::find($_GET["id"]);
55
}

tests/TestHelper.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
<?php
2-
require_once("braintree_init.php");
2+
session_start();
3+
require_once("vendor/autoload.php");
4+
5+
$dotenv = new Dotenv\Dotenv(__DIR__ . "/../");
6+
$dotenv->load();
7+
8+
Braintree\Configuration::environment(getenv('BT_ENVIRONMENT'));
9+
Braintree\Configuration::merchantId(getenv('BT_MERCHANT_ID'));
10+
Braintree\Configuration::publicKey(getenv('BT_PUBLIC_KEY'));
11+
Braintree\Configuration::privateKey(getenv('BT_PRIVATE_KEY'));

0 commit comments

Comments
 (0)