Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sroehrl/neoanio-rest-starter
Simple project setup for stateless PHP REST-apis based on neoan.io LENKRAD
https://github.com/sroehrl/neoanio-rest-starter
json-api jwt-auth php php8 rest-api stateless
Last synced: about 1 month ago
JSON representation
Simple project setup for stateless PHP REST-apis based on neoan.io LENKRAD
- Host: GitHub
- URL: https://github.com/sroehrl/neoanio-rest-starter
- Owner: sroehrl
- License: mit
- Created: 2022-10-27T22:41:04.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T22:32:41.000Z (7 months ago)
- Last Synced: 2024-09-30T18:10:48.441Z (about 2 months ago)
- Topics: json-api, jwt-auth, php, php8, rest-api, stateless
- Language: PHP
- Homepage:
- Size: 140 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Basic neoan.io Lenkrad REST-API starter kit with authentication
This is a very light project setup designed to get your REST-api up and running in no time.
## Requirements
- php8.1
- composer ^2
- SQLite## Installation
`composer create-project neoan.io/rest-api-starter-project my-app`
`cd my-app`
`composer update`
`php install`
To run:
`php dev`The, visit `http://127.0.0.1:8080`
## Basic tutorial
This project ships with a basic tutorial to get you started. For deeper understanding, please visit the lenkrad docs:
[neoan.io lenkrad](https://github.com/sroehrl/neoan.io-lenkrad-core#neoanio-lenkrad-core)## Authentication
After installation, you can register a user against POST /api/auth/register (src/Auth/Api/Register.php) with a payload containing email and password:> curl -X POST -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "123456"}' http://127.0.0.1:8080/api/auth/register
Authenticated calls will require the provided JWT-token
The login endpoint is `/api/auth/authenticate` (src/Auth/Api/Authenticate.php) and the endpoint `/api/auth/me` (src/Auth/Api/Me.php) returns the current user.
## Restricting routes
Middleware can be chained prior to routes in the respective Attributes (see src/Auth/Api/ME.php for clarification)
## Understanding the capabilities
The folder src/Example should give you a good starting point for intuitive understanding of how the LENKRAD core is used in this starter.
Be aware that you are completely free regarding structure. What you find in this starter is a mere example.## Security / Before you deploy
Your checklist:
- .env file update
- folder src/Example necessary?
- is only the folder /public exposed to the web?## Change from SQLite to MySQL or MariaDB
First, add the following information to your .env file
- DB_HOST
- DB_NAME
- DB_USER
- DB_PASSWORD
- DB_CHARSET
- DB_PORTMake sure that the selected database is created. Then, change the constructor of `config/Database.php` to use the method
`useMySql` instead of `useSQLite`.When migrating, use the dialect keyword `mysql` instead of `sqlite`:
`php cli migrate:models mysql`