An open API service indexing awesome lists of open source software.

https://github.com/boolfalse/laravel-sanctum-api

Laravel 8 Sanctum API with SQLite
https://github.com/boolfalse/laravel-sanctum-api

laravel sanctum sqlite

Last synced: 7 months ago
JSON representation

Laravel 8 Sanctum API with SQLite

Awesome Lists containing this project

README

          

## Sanctum REST API with SQLite (Laravel v8).

### Prerequisites:

- PHP, PHP-CLI >=7.4 & Composer;
- Apache webserver;
- SQLite driver installed;

### Installation:

```
git clone laravel-sanctum-api
cd laravel-sanctum-api/
```

- Install SQLite driver for UNIX OS and ".env".
```
sudo apt update
sudo apt install php-sqlite3
sudo apt install php7.4-sqlite3
sudo systemctl restart apache2
```

- [About Setup](https://stackoverflow.com/a/37266353) Laravel resources (files/folders) ownerships/permissions
```
# one-time command
sudo usermod -a -G www-data $USER

# setup ownerships/permissions
sudo chown -R $USER:www-data storage/ bootstrap/cache/
sudo chgrp -R www-data storage bootstrap/cache/
sudo chmod -R ug+rwx storage bootstrap/cache/

# setup SQLite file write permissions for avoiding this error:
# SQLSTATE[HY000]General Error: 8 attempt to write a readonly database
# NOTE: we will work on "database" folder, but not only on "database.sqlite" file
sudo chgrp -R www-data database/
chown -R $USER database/

# after this make sure you have appropriate permission/ownership
# for "database/database.sqlite" file
cd database/
stat -c "%a %n" *
ls -la
```

- Add "Accept: application/json" to the POST,PUT,DELETE API-endpoints.

### Resources:

- [Postman Collection shared public link](https://www.getpostman.com/collections/04fd3912e4c490df29da)
- [Traversy Media - Mar 31, 2021 - Laravel 8 REST API With Sanctum Authentication](https://www.youtube.com/watch?v=MT-GJQIY3EU)
- [Brad Traversy - Laravel Sanctum API](https://github.com/bradtraversy/laravel-sanctum-api)
- [Laravel Sanctum - official documentation](https://laravel.com/docs/8.x/sanctum)
- [failed to open stream: Permission denied](https://stackoverflow.com/a/48794292)
- [Permission denied ".../storage/logs/laravel.log could not be opened"](https://github.com/BookStackApp/BookStack/issues/436#issuecomment-395964366)

### Developed by:

[BoolFalse](https://boolfalse.com/)