The framework includes several security features to protect your application:
Always use prepared statements:
// Good - uses prepared statements
$sql = "SELECT * FROM users WHERE email = :email";
$user = $this->query($sql, ['email' => $email])->fetch();
// Bad - vulnerable to SQL injection
$sql = "SELECT * FROM users WHERE email = '$email'"; // DON'T DO THIS!
Template engine automatically escapes output:
<!-- Escaped (safe) -->
{{ $user->name }}
<!-- Raw HTML (use with caution) -->
{!! $trustedHtml !!}
Required for all POST requests:
<form method="POST">
@php echo csrf_field(); @endphp
<!-- form fields -->
</form>
// Hashing passwords
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
// Verifying passwords
if (password_verify($inputPassword, $user->password)) {
// Password is correct
}
Sessions are configured with secure settings:
httponly - Prevents JavaScript access to cookiessecure - Cookies only sent over HTTPS (in production)samesite - CSRF protection