Make sure you’ve completed the installation before proceeding with this guide.
Understanding the request flow
When a user visits your S-PHP application, the request flows through several components:- Entry Point (
public/index.php) - Handles autoloading and routes to web/API handlers - Router - Matches the URL to a route definition
- Middleware - Checks permissions and authentication (optional)
- Controller - Processes the request and prepares data
- View - Renders the response to the user
Your first route
Routes are defined inapp/router/web.php. Here’s a simple example from the source:
app/router/web.php
Your first controller
Controllers live inapp/Controllers/. Here’s a basic controller:
app/Controllers/HomeController.php
Dynamic routes
S-PHP supports dynamic parameters in routes using{parameter} syntax:
Building a simple page
Let’s build a complete feature from scratch.Working with databases
S-PHP provides a simple database interface through the controller’s$db property:
Using middleware
Protect routes with middleware by adding it as the 4th parameter:app/Middleware/VerifiedUser.php
Handling POST requests
Add a POST route for form submissions:CLI commands
S-PHP includes a powerful CLI tool for common tasks:Next steps
Now that you’ve built your first route, explore more features:Controllers
Learn about controllers and request handling
Models
Work with the database using models
Views
Create dynamic templates with layouts
Authentication
Add user authentication with JWT