You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+25-66Lines changed: 25 additions & 66 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,12 @@
1
-
Hello! Thank you for choosing to help contribute to the python-http-client. There are many ways you can contribute and help is always welcome.
1
+
Hello! Thank you for choosing to help contribute to the php-http-client. There are many ways you can contribute and help is always welcome.
2
2
3
-
We use [Milestones](https://github.com/sendgrid/python-http-client/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
3
+
We use [Milestones](https://github.com/sendgrid/php-http-client/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
4
4
5
5
*[Feature Request](#feature_request)
6
6
*[Submit a Bug Report](#submit_a_bug_report)
7
7
*[Improvements to the Codebase](#improvements_to_the_codebase)
8
8
*[Understanding the Code Base](#understanding_the_codebase)
9
9
*[Testing](#testing)
10
-
*[Testing Multiple Versions of Python](#testing_multiple_versoins_of_python)
See the [examples folder](https://github.com/sendgrid/python-http-client/tree/master/examples) to get started quickly.
90
+
See the [examples folder](https://github.com/sendgrid/php-http-client/tree/master/examples) to get started quickly.
92
91
93
92
<aname="understanding_the_codebase"></a>
94
93
## Understanding the Code Base
@@ -97,15 +96,15 @@ See the [examples folder](https://github.com/sendgrid/python-http-client/tree/ma
97
96
98
97
Working examples that demonstrate usage.
99
98
100
-
**client.py**
99
+
**client.php**
101
100
102
-
An HTTP client with a fluent interface using method chaining and reflection. By returning self on [__getattr__](https://github.com/sendgrid/python-http-client/blob/master/client.py#L74) and [_()](https://github.com/sendgrid/python-http-client/blob/master/client.py#L70), we can dynamically build the URL using method chaining and [__getattr__](https://github.com/sendgrid/python-http-client/blob/master/client.py#L74) allows us to dynamically receive the method calls to achieve reflection.
101
+
An HTTP client with a fluent interface using method chaining and reflection. By returning self on [__call](https://github.com/sendgrid/php-http-client/blob/master/lib/client.php#L212) and [_()](https://github.com/sendgrid/php-http-client/blob/master/lib/client.pph#L198), we can dynamically build the URL using method chaining and [__call](https://github.com/sendgrid/php-http-client/blob/master/lib/client.php#L212) allows us to dynamically receive the method calls to achieve reflection.
103
102
104
103
This allows for the following mapping from a URL to a method chain:
105
104
106
-
`/api_client/{api_key_id}/version` maps to `client.api_client._(api_key_id).version.<method>()` where <method> is a [HTTP verb](https://github.com/sendgrid/python-http-client/blob/master/client.py#L24).
105
+
`/api_client/{api_key_id}/version` maps to `client->api_client().->_($api_key_id)->version-><method>()` where <method> is a [HTTP verb](https://github.com/sendgrid/php-http-client/blob/master/lib/client.php#L94).
107
106
108
-
**congfig.py**
107
+
**congfig.php**
109
108
110
109
Loads the environment variables.
111
110
@@ -114,66 +113,26 @@ Loads the environment variables.
114
113
115
114
All PRs require passing tests before the PR will be reviewed.
116
115
117
-
All test files are in the `[tests](https://github.com/sendgrid/python-http-client/tree/master/tests)` directory.
116
+
All test files are in the `[test/unit](https://github.com/sendgrid/php-http-client/tree/master/test/unit)` directory.
118
117
119
-
For the purposes of contributing to this repo, please update the [`test_unit.py`](https://github.com/sendgrid/python-http-client/blob/master/tests/test_unit.py) file with unit tests as you modify the code.
118
+
For the purposes of contributing to this repo, please update the [`ClientTest.php`](https://github.com/sendgrid/php-http-client/blob/master/test/unit/ClientTest.php) file with unit tests as you modify the code.
120
119
121
-
For Python 2.6.*:
122
-
123
-
`unit2 discover -v`
124
-
125
-
For Python 2.7.* and up:
126
-
127
-
`python -m unittest discover -v`
128
-
129
-
<aname="testing_multiple_versoins_of_python"></a>
130
-
## Testing Multiple Versions of Python
131
-
132
-
All PRs require passing tests before the PR will be reviewed.
133
-
134
-
### Prequisites: ###
135
-
136
-
The above local "Initial setup" is complete
137
-
138
-
*[pyenv](https://github.com/yyuu/pyenv)
139
-
*[tox](https://pypi.python.org/pypi/tox)
140
-
141
-
### Initial setup: ###
142
-
143
-
Add ```eval "$(pyenv init -)"``` to your shell environment (.profile, .bashrc, etc) after installing tox, you only need to do this once.
Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning.
Please run your code through [pyflakes](https://pypi.python.org/pypi/pyflakes), [pylint](https://www.pylint.org/) and [pep8](https://pypi.python.org/pypi/pep8)
129
+
Please run your code through [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)
172
130
173
131
### Directory Structure
174
132
175
-
* `examples` for example calls
176
-
* `tests`, for all tests
133
+
*`examples`, for example calls
134
+
*`test\unit`, for all tests
135
+
* 'lib`, for source code
177
136
178
137
## Creating a Pull Request<aname="creating_a_pull_request"></a>
179
138
@@ -182,11 +141,11 @@ Please run your code through [pyflakes](https://pypi.python.org/pypi/pyflakes),
182
141
183
142
```bash
184
143
# Clone your fork of the repo into the current directory
Add php-http-client to your `composer.json` file. If you are not using [Composer](http://getcomposer.org), you should be. It's an excellent way to manage dependencies in your PHP application.
39
+
40
+
```json
41
+
{
42
+
"require": {
43
+
"sendgrid/php-http-client": "~1"
44
+
}
45
+
}
46
+
```
47
+
48
+
Then at the top of your PHP script require the autoloader:
49
+
50
+
```bash
51
+
require 'vendor/autoload.php';
52
+
```
53
+
54
+
or
55
+
56
+
`pear install php-http-client`
57
+
58
+
## Usage ##
59
+
60
+
Following is an example using SendGrid. You can get your free account [here](https://sendgrid.com/free?source=php-http-client).
61
+
62
+
First, update your .env with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) and HOST. For this example HOST=https://api.sendgrid.com.
63
+
64
+
Following is an abridged example, here is the [full working code](https://github.com/sendgrid/php-http-client/tree/master/examples).
65
+
66
+
```php
67
+
<?php
68
+
include 'php-http-client';
69
+
$config = new SendGrid\Config(dirname(__DIR__), '.env');
70
+
$api_key = getenv('SENDGRID_API_KEY');
71
+
$headers = array(
72
+
'Content-Type: application/json',
73
+
'Authorization: Bearer '.$api_key
74
+
);
75
+
$client = new SendGrid\Client('https://e9sk3d3bfaikbpdq7.stoplight-proxy.io', $headers, '/v3', null);
We encourage contribution to our libraries, please see our [CONTRIBUTING](https://github.com/sendgrid/php-http-client/blob/master/CONTRIBUTING.md) guide for details.
0 commit comments