|
| 1 | +# Quick Start - bitshost/php-crud-api-generator |
| 2 | + |
| 3 | +**Get started in 5 minutes!** |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Step 1: Install |
| 8 | + |
| 9 | +```bash |
| 10 | +composer require bitshost/php-crud-api-generator |
| 11 | +``` |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Step 2: Copy 3 files to project root |
| 16 | + |
| 17 | +```bash |
| 18 | +copy vendor\bitshost\php-crud-api-generator\public\index.php index.php |
| 19 | +copy vendor\bitshost\php-crud-api-generator\dashboard.html dashboard.html |
| 20 | +copy vendor\bitshost\php-crud-api-generator\health.php health.php |
| 21 | +``` |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Step 3: Edit index.php (2 lines) |
| 26 | + |
| 27 | +Change config paths to point to vendor: |
| 28 | + |
| 29 | +```php |
| 30 | +// Change this: |
| 31 | +$dbConfig = require __DIR__ . '/config/db.php'; |
| 32 | +$apiConfig = require __DIR__ . '/config/api.php'; |
| 33 | + |
| 34 | +// To this: |
| 35 | +$dbConfig = require __DIR__ . '/vendor/bitshost/php-crud-api-generator/config/db.php'; |
| 36 | +$apiConfig = require __DIR__ . '/vendor/bitshost/php-crud-api-generator/config/api.php'; |
| 37 | +``` |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## Step 4: Configure (in vendor directory) |
| 42 | + |
| 43 | +```bash |
| 44 | +notepad vendor\bitshost\php-crud-api-generator\config\db.php |
| 45 | +notepad vendor\bitshost\php-crud-api-generator\config\api.php |
| 46 | +``` |
| 47 | + |
| 48 | +**db.php:** |
| 49 | +```php |
| 50 | +return [ |
| 51 | + 'host' => 'localhost', |
| 52 | + 'dbname' => 'your_database', |
| 53 | + 'user' => 'root', |
| 54 | + 'pass' => '', |
| 55 | + 'charset' => 'utf8mb4' |
| 56 | +]; |
| 57 | +``` |
| 58 | + |
| 59 | +**api.php - Generate JWT secret:** |
| 60 | +```bash |
| 61 | +php -r "echo bin2hex(random_bytes(32));" |
| 62 | +``` |
| 63 | + |
| 64 | +Paste result into api.php: |
| 65 | +```php |
| 66 | +'jwt_secret' => 'YOUR_64_CHAR_SECRET_HERE', |
| 67 | +``` |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## Step 5: Run! |
| 72 | + |
| 73 | +```bash |
| 74 | +php -S localhost:8000 |
| 75 | +``` |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Test |
| 80 | + |
| 81 | +```bash |
| 82 | +# Login |
| 83 | +curl -X POST -d "username=admin&password=password123" http://localhost:8000/?action=login |
| 84 | + |
| 85 | +# View dashboard |
| 86 | +http://localhost:8000/dashboard.html |
| 87 | +``` |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Summary |
| 92 | + |
| 93 | +**3 files copied:** |
| 94 | +- index.php (2 lines modified) |
| 95 | +- dashboard.html (0 modifications) |
| 96 | +- health.php (0 modifications) |
| 97 | + |
| 98 | +**2 files edited:** |
| 99 | +- vendor/.../config/db.php |
| 100 | +- vendor/.../config/api.php |
| 101 | + |
| 102 | +**Total code changes: 2 lines!** 🎉 |
| 103 | + |
| 104 | +That's it! Your API is ready. All configs stay in vendor directory - clean and simple! |
0 commit comments