PHP Classes

File: docs/QUICK_START.md

Recommend this page to a friend!
  Packages of Adrian M   PHP CRUD API Generator   docs/QUICK_START.md   Download  
File: docs/QUICK_START.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PHP CRUD API Generator
Create an API to access MySQL database record
Author: By
Last change: Update of docs/QUICK_START.md
Date: 11 months ago
Size: 2,254 bytes
 

 

Contents

Class file image Download

Quick Start (v2.1+)

Get a working API in a few minutes. Do not edit files under vendor/.

Library install (recommended)

composer require bitshost/php-crud-api-generator

# Entrypoint (+ optional ops UI)
copy vendor\bitshost\php-crud-api-generator\public\index.php index.php
copy vendor\bitshost\php-crud-api-generator\dashboard.html dashboard.html
copy vendor\bitshost\php-crud-api-generator\health.php health.php

# Project-local configs (skips files that already exist)
php vendor\bitshost\php-crud-api-generator\scripts\install-config.php .

# Edit YOUR project config
notepad config\db.php
notepad config\api.php

# Sanity check
php vendor\bitshost\php-crud-api-generator\scripts\doctor.php

php -S localhost:8000

Linux/macOS: use cp instead of copy.

Standalone project

composer create-project bitshost/php-crud-api-generator my-api
cd my-api

php scripts/install-config.php .
# edit config/db.php and config/api.php
php scripts/doctor.php

php -S localhost:8000 -t public

Minimal config checklist

In config/db.php: host, dbname, user, pass.

In config/api.php (production):

  • `auth_enabled` => `true`
  • strong `jwt_secret` / `api_keys`
  • set `allowed_tables` to an explicit list of business tables
  • keep `denied_tables` for system tables (`api_users`, ?)
  • protect `dashboard.html` / `health.php` ? see DASHBOARD_SECURITY.md

Smoke test

# With Basic auth (default example method may vary ? check your api.php)
curl -u admin:secret "http://localhost:8000/index.php?action=tables"

# List rows
curl -u admin:secret "http://localhost:8000/index.php?action=list&table=users"

# Delete must be POST
curl -u admin:secret -X POST "http://localhost:8000/index.php?action=delete&table=users&id=1"

Design model (important)

This API is a data plane: CRUD + bulk + filters on tables.

Related data / business workflows are composed outside (JavaScript, mobile app, upMVC). See CLIENT_SIDE_JOINS.md.

Next reading