Skip to content

Commit cf164ac

Browse files
committed
Merge pull request #3 from GiampaoloFalqui/psr-4-laravel-4.2
PSR-0 => PSR-4, adds Laravel 4.2 implementation
2 parents 424b2c8 + 3d117ad commit cf164ac

30 files changed

Lines changed: 222 additions & 73 deletions

README.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ php composer.phar require jlinn/mandrill-api-php:~1.0
1717

1818
Usage
1919
=====
20+
2021
Sending a Message
2122
-----------------
2223

2324
```php
24-
use Mandrill\Mandrill;
25-
use Mandrill\Struct\Message;
26-
use Mandrill\Struct\Recipient;
25+
use Jlinn\Mandrill\Mandrill;
26+
use Jlinn\Mandrill\Struct\Message;
27+
use Jlinn\Mandrill\Struct\Recipient;
2728

2829
// instantiate a client object
2930
$mandrill = new Mandrill('your_api_key');
@@ -48,4 +49,39 @@ $message->addRecipient($recipient);
4849

4950
// send the message
5051
$response = $mandrill->messages()->send($message);
51-
```
52+
```
53+
54+
Usage with Laravel 4.x
55+
=====
56+
57+
We have built a factory so that it's easier to use with Laravel 4.x facades.
58+
59+
Configuration
60+
-----------------
61+
62+
In order to publish the package configuration you need to perform the following command:
63+
64+
```
65+
php artisan config:publish jlinn/mandrill-api-php
66+
```
67+
68+
Change then the `secret` variable with your Mandrill secret key.
69+
70+
Sending a Message
71+
-----------------
72+
73+
```php
74+
$api = Mandrill::api();
75+
76+
$message = Mandrill::message([
77+
'text' => 'Hello, *|NAME|*!',
78+
'subject' => 'Test',
79+
'from_email' => 'test@example.com',
80+
'from_name' => 'Mandrill API Test'
81+
]);
82+
83+
$recipient = Mandrill::recipient('recipient.email@example.com', 'Recipient Name');
84+
$recipient->addMergeVar('NAME', $recipient->name);
85+
$message->addRecipient($recipient);
86+
87+
$response = $api->messages()->send($message);

composer.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@
1919
},
2020
"autoload": {
2121
"psr-0": {
22-
"Mandrill": "src/",
23-
"Mandrill\\Tests": "tests/"
22+
"Jlinn\\": "src/Jlinn/"
23+
},
24+
"psr-4": {
25+
"Jlinn\\": "src/Jlinn/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-0": {
30+
"Jlinn\\": "tests/"
31+
},
32+
"psr-4": {
33+
"Jlinn\\": "tests/"
2434
}
2535
}
2636
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* Time: 4:46 PM
66
*/
77

8-
namespace Mandrill;
8+
namespace Jlinn\Mandrill;
99

1010
use Guzzle\Http\Client;
1111
use Guzzle\Http\Exception\ServerErrorResponseException;
12-
use Mandrill\Exception\APIException;
12+
use Jlinn\Mandrill\Exception\APIException;
1313

1414
abstract class Api{
1515
const BASE_URL = 'https://mandrillapp.com/api/1.0/';
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
* Time: 4:56 PM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

10-
11-
use Mandrill\Api;
10+
use Jlinn\Mandrill\Api;
1211

1312
/**
1413
* Class Exports
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
* Time: 4:52 PM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

10-
11-
use Mandrill\Api;
10+
use Jlinn\Mandrill\Api;
1211

1312
/**
1413
* Class Inbound
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
* Time: 5:04 PM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

10-
11-
use Mandrill\Api;
10+
use Jlinn\Mandrill\Api;
1211

1312
/**
1413
* Class Ips
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* Time: 11:55 AM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

1010
use Guzzle\Http\Client;
11-
use Mandrill\Api;
12-
use Mandrill\Struct\Message;
11+
use Jlinn\Mandrill\Api;
12+
use Jlinn\Mandrill\Struct\Message;
1313

1414
/**
1515
* Class Messages
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
* Time: 3:37 PM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

10-
11-
use Mandrill\Api;
10+
use Jlinn\Mandrill\Api;
1211

1312
/**
1413
* Class Rejects
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
* Time: 3:49 PM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

10-
11-
use Mandrill\Api;
10+
use Jlinn\Mandrill\Api;
1211

1312
/**
1413
* Class Senders
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
* Time: 4:41 PM
66
*/
77

8-
namespace Mandrill\Api;
8+
namespace Jlinn\Mandrill\Api;
99

10-
11-
use Mandrill\Api;
10+
use Jlinn\Mandrill\Api;
1211

1312
/**
1413
* Class Subaccounts

0 commit comments

Comments
 (0)