Simple Laravel API Server with JWT authentication, and SQLite persistence - Provided by AppSeed App Generator and UPDIVISION.
Features:
- API Definition - the unified API structure implemented by this server
- Simple, intuitive codebase - can be extended with ease.
- Stack: PHP 7.4+ / Laravel / Doctrine
- JWT Authentication
Can be used with other React Starters for a complete Full-Stack experience:
React Node JS Berry | React Node Soft Dasard | React Node Datta Able |
---|---|---|
![]() | ![]() | ![]() |
- PHP 7.4+
- Extensions (check the #Troubleshooting section for installation info)
php-xml
php7.4-sqlite
Step #1 - Clone the project
$ git clone https://.com/app-generator/api-server-laravel.git
$ cd api-server-laravel
Step #2 - Install dependencies
$ composer install
$ cp .env.example .env
$ php artisan key:generate
Step #3 - Generate a secret
key used by JWT Authentication Flow
$ php artisan jwt:secret
Step #4 - Set up the database
$ touch database/database.sqlite
$ php artisan migrate
Step #5 - Start the server
$ php -S localhost:5000 server.php
To have a successful compilation of this product, make sure you have the following PHP extensions installed and enabled:
php-xml
- required by Php-Unitphp7.4-sqlite
- The SQLite driver required by Laravel ORM
$ # Php XML - required by Php Unit
$ sudo apt install php-xml php-cli php-mbstring php7.4-sqlite
< ROOT >
|
|-- app/ # Implements APP Bussiness Logic
|-- config/ # Configuration
|-- public/ # Public folder
|-- routes/ # Application ROutes
|-- tests/ # Tests
|
|-- server.php # API Entry Point
|-- .env # Specify the ENV variables
|
|-- ************************************************************************
For a fast set up, use this POSTMAN file: api_sample
Register -
api/users/register
POST api/users/register
Content-Type: application/json
{
"username":"test",
"password":"pass",
"email":"[email protected]"
}
Login -
api/users/login
POST /api/users/login
Content-Type: application/json
{
"password":"pass",
"email":"[email protected]"
}
Logout -
api/users/logout
POST api/users/logout
Content-Type: application/json
authorization: JWT_TOKEN (returned by Login request)
{
"token":"JWT_TOKEN"
}
Laravel API Server - provided by AppSeed App Generator