Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Add Sentry (#43)
Browse files Browse the repository at this point in the history
* Add sentry.php to configs
* Add `debug-sentry` route
  • Loading branch information
gomzyakov authored May 6, 2022
1 parent 3b390ad commit 6a89dd7
Show file tree
Hide file tree
Showing 7 changed files with 1,642 additions and 248 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_KEY=base64:g3cPbmSz3AC3CoGXtbK81jFgYJnobc4iT27AwRs+FQc=
APP_DEBUG=true
APP_URL=http://localhost

Expand All @@ -10,6 +10,7 @@ LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
# DB_HOST=mysql <-- for a local dev
DB_PORT=3306
DB_DATABASE=secretnotes
DB_USERNAME=root
Expand Down Expand Up @@ -50,3 +51,6 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

SENTRY_LARAVEL_DSN=https://[email protected]/6382169
SENTRY_TRACES_SAMPLE_RATE=1.0
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@

### Local development

When you pull this project to another computer that has no PHP or Composer installed, you cant run `sail` command
because there is no vendor folder.

Solution is https://laravel.com/docs/9.x/sail#installing-composer-dependencies-for-existing-projects

```bash
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/opt \
-w /opt \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs
```
Instead of repeatedly typing `vendor/bin/sail` to execute Sail commands, you may wish to configure a Bash alias:

```bash
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
```

sail artisan migrate:fresh --seed

>If needed, change DB_HOST to `mysql` (for local development)
Чтобы собрать фронт (CSS, JS):
sail npm run dev

Expand All @@ -22,8 +45,8 @@ sail down --rmi all -v

Создаём VDS-виртуалку, например в [NetAngels](https://panel.netangels.ru).


Заходим по SSH и проверяем версию PHP (`php -v). Если необходимо, [обновляемся до PHP 8](https://php.watch/articles/php-8.0-installation-update-guide-debian-ubuntu):
Заходим по SSH и проверяем версию PHP (`php -v). Если
необходимо, [обновляемся до PHP 8](https://php.watch/articles/php-8.0-installation-update-guide-debian-ubuntu):

```bash
sudo apt update
Expand Down Expand Up @@ -56,25 +79,22 @@ php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
```


>Далее делаем всё от пользователя `web`, не `root`!!!
> Далее делаем всё от пользователя `web`, не `root`!!!



ssh-keygen




В репозитории на GitHub, в разделе `Settings > Secrets > Actions` задаём значения:

- `SSH_PRIVATE_KEY`. If you don’t have this you can run ssh-keygen in your server terminal to generate a new key, then run the command cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys to allow connection to the private key.
- `SSH_PRIVATE_KEY`. If you don’t have this you can run ssh-keygen in your server terminal to generate a new key, then
run the command cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys to allow connection to the private key.
- `SSH_HOST`. This is the IP address of the server.
- `SSH_USERNAME`. This is the server username, in my case it’s root . If you don’t know your username you can use the whoami command on your server to check.

В репозитории, в разделе `Deploy keys`, задаём значение публичного ключа с виртуальной машины (получить можно через `cat ~/.ssh/id_rsa.pub`). Это позволит деплоиться через `git pull` с VDS.

- `SSH_USERNAME`. This is the server username, in my case it’s root . If you don’t know your username you can use the
whoami command on your server to check.

В репозитории, в разделе `Deploy keys`, задаём значение публичного ключа с виртуальной машины (получить можно
через `cat ~/.ssh/id_rsa.pub`). Это позволит деплоиться через `git pull` с VDS.

/var/www/web/sites

Expand All @@ -84,7 +104,6 @@ git clone [email protected]:gomzyakov/secretnotes.git secretnotes.ru
/var/www/web/sites/secretnotes.ru
php -r "file_exists('.env') || copy('.env.example', '.env');"
composer install
Expand All @@ -93,20 +112,16 @@ chmod -R 777 storage bootstrap/cache
php artisan key:generate
Вносим корректные реквизиты в `.env` файл:
Создаём БД `secretnotes` через phpMyAdmin
Создаём БД `secretnotes` через phpMyAdmin
php artisan migrate:fresh --seed
## Front
На виртуалке:
cd ~
curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
Expand All @@ -117,7 +132,6 @@ v16.6.1
sudo apt install npm
После этого билдим непосредственно фронтовые зависимости:
npm install
Expand Down
9 changes: 9 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ public function register()
//
});
}

public function report(Throwable $exception)
{
if (app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}

parent::report($exception);
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"laravel/framework": "^9.2",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"hashids/hashids": "^4.1"
"hashids/hashids": "^4.1",
"sentry/sentry-laravel": "^2.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
Expand Down
Loading

0 comments on commit 6a89dd7

Please sign in to comment.