|
1 | | -# BSA 2019 Thread backend |
| 1 | +# BSA 2019 Thread (backend) |
| 2 | + |
| 3 | +## Technologies |
| 4 | + |
| 5 | +* PHP 7.2 || 7.3 |
| 6 | +* [Laravel 5.8](https://laravel.com) |
| 7 | +* [Docker](https://www.docker.com/) |
| 8 | +* [Docker-compose](https://docs.docker.com/compose/) |
| 9 | +* [Beanstalkd](https://github.com/beanstalkd/beanstalkd) - message queue (очередь сообщений для обработки тяжелых задач асинхронно) |
| 10 | +* [REST API](https://ru.wikipedia.org/wiki/REST) |
| 11 | +* [CORS](https://developer.mozilla.org/ru/docs/Web/HTTP/CORS) |
| 12 | +* [JWT](https://ru.wikipedia.org/wiki/JSON_Web_Token) tokens |
| 13 | +* Websockets and [Pusher](https://pusher.com/) service |
| 14 | +* MySQL 5.7 |
2 | 15 |
|
3 | 16 | ## Install |
| 17 | + |
| 18 | +Set your .env vars: |
| 19 | +```bash |
| 20 | +cp .env.example .env |
| 21 | +``` |
| 22 | + |
| 23 | +### Launch local environment: |
| 24 | + |
| 25 | +Step inside project directory |
| 26 | +```bash |
| 27 | +cd <project_dir>/backend |
| 28 | +``` |
| 29 | + |
| 30 | +Start application docker containers: |
| 31 | +``` bash |
| 32 | +docker-compose up -d |
| 33 | +``` |
| 34 | + |
| 35 | +Install composer dependencies and generate app key: |
| 36 | +```bash |
| 37 | +docker exec -it thread-app composer install |
| 38 | +docker exec -it thread-app php artisan key:generate |
| 39 | +``` |
| 40 | + |
| 41 | +Database migrations install (set proper .env vars) |
| 42 | +```bash |
| 43 | +docker exec -it thread-app php artisan migrate |
| 44 | +docker exec -it thread-app php artisan db:seed |
| 45 | +``` |
| 46 | + |
| 47 | +Generate jwt key and create link to public folder for file uploads (you should have `FILESYSTEM_DRIVER=public` in .env): |
| 48 | +```bash |
| 49 | +docker exec -it thread-app php artisan jwt:generate |
| 50 | +docker exec -it thread-app php artisan storage:link |
| 51 | +``` |
| 52 | + |
| 53 | +Application server should be ready on http://localhost:<APP_PORT> |
| 54 | + |
| 55 | +Pusher websocket server install: |
| 56 | +* Create an account and application on [pusher.com](https://pusher.com/) and copy your credentials to your .env (`PUSHER_APP_ID=...`). |
| 57 | +* Update your .env (`QUEUE_CONNECTION=beanstalkd`, `BROADCAST_DRIVER=pusher`) and launch beanstalkd queue listening to messages by `docker exec -it thread-app php artisan queue:work` |
| 58 | + |
| 59 | +Emails processing .env settings (you can use [mailtrap](https://mailtrap.io/) or your smtp credentials like user@gmail.com): |
| 60 | +```dotenv |
| 61 | +MAIL_DRIVER=smtp |
| 62 | +MAIL_HOST=smtp.mailtrap.io |
| 63 | +MAIL_USERNAME=<mailtrap_key> |
| 64 | +MAIL_PASSWORD=<mailtrap_password> |
| 65 | +MAIL_PORT=587 |
| 66 | +MAIL_FROM_ADDRESS=admin@thread.com |
| 67 | +MAIL_FROM_NAME="BSA Thread Admin" |
| 68 | +``` |
| 69 | + |
| 70 | +You can debug your app with [Telescope](https://laravel.com/docs/5.8/telescope) tool which is installed already :) |
0 commit comments