Core concepts
Core concepts you'll use every day
Essentials
Learn the fundamental concepts you'll use in every Glueful application.
Core Topics
HTTP Layer
- Routing - Define URLs and route parameters
- Controllers - Handle requests and return responses
- Requests & Responses - Work with HTTP data
- Validation - Validate input data
- Typed Request & Response DTOs - Validated input objects and typed output
Data Layer
- Database - Query builder and connections
- ORM - Models, relationships and eager loading
- Migrations - Database schema management
Security
- Authentication - Login, JWT/refresh tokens, browser sessions, API keys
- Identity & User Store - The pluggable user store authentication runs on (the skeleton enables
glueful/users; core ships none)
Learning Path
New to Glueful? Follow this order:
- Routing - Understand how URLs map to code
- Controllers - Learn to structure your application logic
- Database - Query and store data
- Validation - Ensure data integrity
- Authentication - Secure your endpoints
Quick Reference
Common Tasks
Create a new endpoint:
// routes/api.php
$router->get('/users', [UserController::class, 'index']);
Query the database:
// Anywhere you hold an ApplicationContext (in a controller: $this->getContext())
$posts = db($context)->table('posts')->where(['status' => 'published'])->get();
Validate input:
use Glueful\Validation\Support\Rules as RuleFactory;
use Glueful\Validation\ValidationException;
use Glueful\Validation\Rules\{Sanitize, Required, Email as EmailRule, Length};
use Glueful\Helpers\RequestHelper;
$input = RequestHelper::getRequestData($request); // decodes JSON or form bodies
$v = RuleFactory::of([
'email' => [new Sanitize(['trim']), new Required(), new EmailRule()],
'name' => [new Sanitize(['trim','strip_tags']), new Required(), new Length(2, 50)],
]);
if ($errors = $v->validate($input)) {
throw new ValidationException($errors);
}
$data = $v->filtered();
Return JSON:
return Response::success($data);
Next Steps
After mastering the essentials, explore: