This template is designed for teams that want PHP as backend and React as frontend without using a full PHP framework.
Use this guide when starting a new project so you can safely remove demo parts and keep the core architecture intact.
Do not delete these unless you are intentionally replacing the backend architecture.
public/index.php- front controller entry point.bootstrap.php- environment, logging, and Eloquent bootstrap.app/Core/*- request/response, router, container, validation, exceptions.config/*.php- centralized environment-backed application config.routes/api.php- API route definitions.routes/web.php- SPA + static asset fallback.app/Providers/AppServiceProvider.php- container bindings.app/Http/Middleware/CorsMiddleware.php- API CORS support.composer.json+vendor/(after install) - backend dependencies/autoload.vite.config.ts- frontend build + dev proxy behavior.
These are demo app examples and can be replaced with your own domain.
src/App.tsxand related UI for TaskFlow demo.app/Models/Todo.php.app/Controllers/Api/TodoController.php.- Todo routes in
routes/api.php. seed.phpdemo task data.
If you do not need database-driven SEO injection, you can remove:
app/Models/Seo.phpapp/Models/Setting.phpapp/Controllers/Api/SeoController.phpapp/Controllers/Api/SettingController.php- SEO/settings routes in
routes/api.php - SEO lookup logic inside
app/Controllers/Web/FrontendController.php seoandsettingstable creation inmigrate.php- SEO/setting seed data in
seed.php
If removed, keep a static <title> and meta tags in your frontend index.html build template.
If you do not need API key protection for admin-like routes, remove:
app/Http/Middleware/ApiKeyAuthMiddleware.php- Its usage in
routes/api.php API_KEYfrom.env.example(optional)
If you do not want per-request logs in php_errors.log, remove:
app/Http/Middleware/RequestLoggingMiddleware.php- Its usage in
routes/api.php
- Copy env file:
cp .env.example .env - Set app/database values in
.env. - Replace demo API controllers with your own modules.
- Update
routes/api.phpto match your domain endpoints. - Replace demo React UI in
src/. - Update
migrate.phpandseed.phpwith your schema/data. - Keep API base in frontend as
/api/v1.
- Keep backend routes versioned under
/api/v1. - Keep web fallback in
routes/web.phpfor React SPA routes. - Add middleware at route group level when possible.
- Deleting
public/index.phpand expecting SPA routing to still work. - Moving API paths away from
/api/v1without updating frontend fetch base. - Removing
bootstrap.phpor Dotenv loading while still using env variables. - Deleting
routes/web.phpand breaking deep-link refresh for React routes.
If you want a very small backend, the minimal structure is:
public/index.phpbootstrap.phpapp/Core/*routes/api.phproutes/web.php- one model + one controller + one route group
Everything else can evolve from there.