README.md 2.41 KB
Newer Older
1
2
### Available classes in this library

3
4
- \Library\HttpClientTrait<br>
  Trait for adding a httpClient property to a class.<br>
5
  [code examples](docs/HttpClientTrait.md)
6

7
8
- \Library\LoggerTrait<br>
  Trait for adding a logger property to a class.<br>
9
  [code examples](docs/LoggerTrait.md)
10

11
12
- \Library\Webquery<br>
  Class for sending requests to a WebQuery service and processing the responses.<br>
13
  [code examples](docs/WebQuery.md)
14

15
- \Library\Test\MockHttpClient<br>
16
  A http client class to mock http responses in test code.
17
18
19
20
21

A subclass of \GuzzleHttp\Client with a mock handler
and request history middleware.
Useful for writing tests.

22
### Using the library in other projects
Hoop, Bert Jan de's avatar
Hoop, Bert Jan de committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
To use this repository as a dependency in composer.json
add the following lines:
```javascript
    "repositories": [
        {
            "type": "gitlab",
            "url": "https://git.wur.nl/library/php-modules.git"
        }
    ],
```
This instructs composer to check the library/php-modules repository.
For composer to be able the correctly access the repository it must
be told that it is een alternative gitlab server (domain):
```javascript
    "config": {
        "gitlab-domains": ["git.wur.nl"]
    },
```
And composer needs a personal access token to authenticate at the git.wur.nl server.
Create a personal access token on the git.wur.nl server (in your profile)
and at it to the file '$HOME/.composer/auth.json':
```javascript
{
    "bitbucket-oauth": {},
    "github-oauth": {},
    "gitlab-oauth": {},
    "gitlab-token": { "git.wur.nl": "my-secret-access-token" }
}
```
Now you can at the dependency:
```javascript
    "require": {
55
        "library/php-modules": "^1.0"
Hoop, Bert Jan de's avatar
Hoop, Bert Jan de committed
56
57
58
    },
```
and run 'composer install' or 'composer update'.
59
60

### Running Tests
61
During development you can run tests using the phpunit library. You can use composer to start the test:
62
63
64
65
66
```composer test```
Make sure you test the code before checking it in.

### Vagrant
To make sure you have a production-like environment for testing and developing, a Vagrantfile is available in the project root directory.
67
If vagrant [has been installed](https://www.vagrantup.com/docs/installation/) locally:
68
69
70
```
cd {projectdir}
vagrant up
71
```
72
73
74
Use ```vagrant status``` for more info about the image.
To ssh into the image use: ```vagrant ssh```
The projectdirectory is mounted in the /vagrant directory in the image. Don't forget to run ```composer install``` after the first build inside the vagrant directory.