aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 54a7d4be4bc982e2f47971d4167eb840249ed465 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
55
56
57
58
59
60
# API
RESTful PHP API for Botleagues

**Note: this is a work in progress.**

# License

GPLv3; see the LICENSE file.

# Installation
* Create a new laravel project:

        laravel new <name-of-folder>

* Remove the default content:

        php artisan fresh

* Add the BotleaguesAPI package using composer

* In `config/app.php`, add the following `ServiceProvider`s:

  * `CamilStaps\BotleaguesApi\BotleaguesApiServiceProvider`
  * `Dingo\Api\Provider\LaravelServiceProvider`

* Publish the `api` and `botleaguesapi` configuration files from `camil-staps/botleagues-api`

* In `config/api.php`, set `auth` to:

        'auth' => [
            'basic' => function ($app) {
                return new Dingo\Api\Auth\Provider\Basic($app['auth']);
            },
            'token' => function ($app) {
                return new \CamilStaps\BotleaguesApi\TokenAuthenticationProvider;
            }
        ],

* In `config/botleaguesapi.php`, set `allowed_origin` to (an array of) the allowed origin(s) of API requests. Use `*` for a wildcard.

* In `.env`, set the appropriate configuration values:

  * `APP_ENV`, `APP_DEBUG`, `APP_KEY`, `APP_URL`
  * `DB_HOST`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD`
  * `API_VERSION=v1`, `API_DEBUG`, `API_DOMAIN`
  * `SESSION_DRIVER=array`, to disable the `laravel_session` cookie

* In your `app/Http/Middleware/VerifyCsrfToken.php`, replace the `handle()` function with:

        public function handle($request, Closure $next) {
            return $next($request);
        }

  This disables the default CSRF middleware. For more information, see http://laravel.io/forum/11-14-2014-disabling-the-csrf-middleware-in-laravel-5.

After this, you should be good to go. Add configuration settings and the like as usual.

# Nginx

See `docs/nginx.conf`.