Skip to content

Commit

Permalink
docs: Reduce excessive comments in code examples (#984)
Browse files Browse the repository at this point in the history
* PHP CS Fixer fixes
* Docs: Import classes instead of namespace\class
* Line length reductions
* Prece(n)dence typos
* Remove PHP tailing '?>' tags
* Examples pending for migration: senderauthentication, contactdb
  • Loading branch information
kampalex authored Aug 6, 2020
1 parent 5a6c5c7 commit 7299d3d
Show file tree
Hide file tree
Showing 31 changed files with 620 additions and 662 deletions.
49 changes: 14 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,38 @@ Add Twilio SendGrid to your `composer.json` file. If you are not using [Composer
}
```

#### Alternative: Install package from zip
### Alternative: Install package from zip

If you are not using Composer, simply download and install the **[latest packaged release of the library as a zip](https://github.com/sendgrid/sendgrid-php/releases/download/7.8.1/sendgrid-php.zip)**.

[**⬇︎ Download Packaged Library ⬇︎**](https://github.com/sendgrid/sendgrid-php/releases/download/7.8.1/sendgrid-php.zip)

Previous versions of the library can be found in the [version index](https://sendgrid-open-source.s3.amazonaws.com/index.html) or downloaded directly from [GitHub](https://github.com/sendgrid/sendgrid-php/releases).
Previous versions of the library can be downloaded directly from [GitHub](https://github.com/sendgrid/sendgrid-php/releases).

## Dependencies

- The Twilio SendGrid Service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-php)
- The dependency free [php-http-client](https://github.com/sendgrid/php-http-client)
- The dependency-free [php-http-client](https://github.com/sendgrid/php-http-client)

<a name="quick-start"></a>
# Quick Start

Include the proper lines from below at the top of each example based on your installation method:

```php
<?php
// Uncomment the next line if you're using a dependency loader (such as Composer) (recommended)
// require 'vendor/autoload.php';

// Uncomment the next line if you're not using a dependency loader (such as Composer), replacing <PATH TO> with the path to the sendgrid-php.php file
// require_once '<PATH TO>/sendgrid-php.php';
```

## Hello Email

The following is the minimum needed code to send an email. You may find more examples in our USE_CASES file:

```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Example User");
$email->setSubject("Sending with Twilio SendGrid is Fun");
Expand All @@ -129,17 +130,6 @@ The `SendGrid\Mail` constructor creates a [personalization object](https://sendg
## General v3 Web API Usage (With Fluent Interface)

```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);

Expand All @@ -156,17 +146,6 @@ try {
## General v3 Web API Usage (Without Fluent Interface)

```php
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);

Expand Down
11 changes: 3 additions & 8 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ This documentation is based on our [OAI specification](https://github.com/sendgr
# INITIALIZATION

```php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases
<?php
// Uncomment next line if you're not using a dependency loader (such as Composer)
// require_once '<PATH TO>/sendgrid-php.php';

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
Expand Down
Loading

0 comments on commit 7299d3d

Please sign in to comment.