From 0b76a7d7a366f9318dd5dbb3efe6c9535f761f20 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 23 Jan 2018 14:01:48 -0800 Subject: [PATCH 1/4] Update Docker instructions --- Dockerfile | 13 +++++++++++++ README.md | 3 --- USE_CASES.md | 27 +++++++++++++++++++++++++++ examples/example.php | 1 + 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 USE_CASES.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9592674 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM php:7.1-apache + +ARG sendgrid_apikey +ENV SENDGRID_API_KEY=$sendgrid_apikey + +COPY . /var/www/client +WORKDIR /var/www/client + +RUN apt-get update && \ + apt-get install -y git zip zlib1g-dev && docker-php-ext-install zip +RUN curl --silent --show-error https://getcomposer.org/installer | php + +RUN php composer.phar install \ No newline at end of file diff --git a/README.md b/README.md index 7ff36bd..39a56e6 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ $ cd /path/to/your/app $ mkdir lib $ cd lib $ git clone https://github.com/sendgrid/php-http-client.git -$ git clone https://github.com/sendgrid/sendgrid-php.git ``` In the next step you should create `loader.php`: @@ -82,8 +81,6 @@ And add to `loader.php` code below: require_once __DIR__ . '/lib/php-http-client/lib/Client.php'; require_once __DIR__ . '/lib/php-http-client/lib/Response.php'; -require_once __DIR__ . '/lib/sendgrid-php/lib/SendGrid.php'; - ``` After it you can use `php-http-client` library in your project: diff --git a/USE_CASES.md b/USE_CASES.md new file mode 100644 index 0000000..5c161c6 --- /dev/null +++ b/USE_CASES.md @@ -0,0 +1,27 @@ +This documentation provides examples for specific use cases. Please [open an issue](https://github.com/sendgrid/php-http-client/issues) or make a pull request for any use cases you would like us to document here. Thank you! + +# Table of Contents +* [Docker](#docker) + + +# Docker + +You can run the example code at `examples/example.php` in a Docker container. + +From the root directory: + +```bash +cp examples/.env_sample .env +``` + +Update the `.env` file with your SendGrid API Key. If you don't have one, you can get one [here](https://sendgrid.com/free?source=php-http-client). + +Add the `.env` file to your `.gitignore` file if you are publishing your code publically. + +``` +source .env +docker build --build-arg sendgrid_apikey=$SENDGRID_API_KEY -t client . +docker run client php examples/example.php +``` + +You should see a list of your SendGrid API Keys. diff --git a/examples/example.php b/examples/example.php index 1de093e..107d95a 100644 --- a/examples/example.php +++ b/examples/example.php @@ -4,6 +4,7 @@ // comment out the two includes below // require __DIR__ . '/vendor/autoload.php'; include(dirname(__DIR__) . '/lib/Client.php'); +include(dirname(__DIR__) . '/lib/Response.php'); // This gets the parent directory, for your current directory use getcwd() $path_to_config = dirname(__DIR__); $apiKey = getenv('SENDGRID_API_KEY'); From c82b43b112f6f47cfad50aefaf8d23c2e725f251 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 23 Jan 2018 14:03:58 -0800 Subject: [PATCH 2/4] Add test for Dockerfile --- test/unit/FilesExistTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/FilesExistTest.php b/test/unit/FilesExistTest.php index e15a46b..21a5dc3 100644 --- a/test/unit/FilesExistTest.php +++ b/test/unit/FilesExistTest.php @@ -26,8 +26,8 @@ public function testFileArePresentInRepo() #$composeExists = file_exists('./docker-compose.yml') || file_exists('./docker/docker-compose.yml'); #$this->assertTrue($composeExists); - #$dockerExists = file_exists('./Docker') || file_exists('./docker/Docker'); - #$this->assertTrue($dockerExists); + $dockerExists = file_exists('./Docker') || file_exists('./docker/Docker'); + $this->assertTrue($dockerExists); } } From 8724d54e9c150b2b03a77d42b56e37313e5cdc65 Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 23 Jan 2018 14:07:25 -0800 Subject: [PATCH 3/4] Fix test --- test/unit/FilesExistTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/FilesExistTest.php b/test/unit/FilesExistTest.php index 21a5dc3..8649759 100644 --- a/test/unit/FilesExistTest.php +++ b/test/unit/FilesExistTest.php @@ -26,7 +26,7 @@ public function testFileArePresentInRepo() #$composeExists = file_exists('./docker-compose.yml') || file_exists('./docker/docker-compose.yml'); #$this->assertTrue($composeExists); - $dockerExists = file_exists('./Docker') || file_exists('./docker/Docker'); + $dockerExists = file_exists('./Dockerfile') || file_exists('./docker/Dockerfile'); $this->assertTrue($dockerExists); } } From 78795c7d6d228903e965bc350e039e4ae1ef969a Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Tue, 23 Jan 2018 14:11:00 -0800 Subject: [PATCH 4/4] Fix test --- test/unit/FilesExistTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/unit/FilesExistTest.php b/test/unit/FilesExistTest.php index 8649759..fbba1d9 100644 --- a/test/unit/FilesExistTest.php +++ b/test/unit/FilesExistTest.php @@ -15,6 +15,7 @@ public function testFileArePresentInRepo() $this->assertFileExists("$rootDir/CHANGELOG.md"); $this->assertFileExists("$rootDir/CODE_OF_CONDUCT.md"); $this->assertFileExists("$rootDir/CONTRIBUTING.md"); + $this->assertFileExists("$rootDir/Dockerfile"); $this->assertFileExists("$rootDir/.github/ISSUE_TEMPLATE"); $this->assertFileExists("$rootDir/LICENSE.txt"); $this->assertFileExists("$rootDir/.github/PULL_REQUEST_TEMPLATE"); @@ -25,9 +26,6 @@ public function testFileArePresentInRepo() #$composeExists = file_exists('./docker-compose.yml') || file_exists('./docker/docker-compose.yml'); #$this->assertTrue($composeExists); - - $dockerExists = file_exists('./Dockerfile') || file_exists('./docker/Dockerfile'); - $this->assertTrue($dockerExists); } }