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
Data Layer
- Database - Query builder and connections
- Migrations - Database schema management
- Authentication - JWT and user sessions
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:
$users = $this->getConnection()->table('users')->where(['active' => true])->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();
$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: