In VeltoPHP, the front-end rendering is powered by a lightweight templating engine using the .vel.php file extension. This custom view engine, known as Vel-View, is specifically developed for VeltoPHP and designed to be both intuitive and efficient.
Much like Laravel’s Blade, Vel-View provides a familiar and expressive syntax for embedding dynamic data into HTML. You can output variables using:
# example
{{ $data }} # Automatically escaped (safe for HTML output)
{!! $data !!} # Unescaped (raw HTML output)
This is the heart of the compiler in your templates and replaces them with equivalent PHP code.
#Layout & Section Control
@extends('layout') → Set a layout
@section('content') → Start a section
@endsection → End a section
@yield('content') → Output a section’s content
@include('view') → Include another view
# Control Structures
@if(condition) → if ()
@elseif(condition) → else if ()
@else → else
@endif → end if
@foreach(...) → foreach loop
@endforeach → end of foreach
@forelse(...) → foreach with empty check
@empty → what to show if empty
@endforelse → end of forelse
@for(...) → for loop
@endfor → end of for
@while(...) → while loop
@endwhile → end of while
@php → open <?php
@endphp → close ?>
# Error Handling
@error('email') → Check for validation errors
@enderror → Close error display
# Auth Helpers
@auth → If user is logged in
@endauth
@guest → If user is NOT logged in
@endguest
# CSRF
@csrf → Outputs CSRF token field
# Flash Info
@flash_info(#id) → Show specific flash message with spesific ID
# Active Links
@active('dashboard') → Outputs `active()` for menu highlighting
# Special Tag Handling
@component('name') → Includes a reusable component.
@role('admin') → Only shows content for users with specific roles.
@end_role → Ends the @role block.
# Echo Output Replacements
{{ $data }} → Escaped HTML output using `htmlspecialchars`
{!! $html !!} → Unescaped raw HTML
Once all replacements are done, the template has been converted into pure PHP, which can be cached and rendered efficiently.
This compiler allows you to:
VeltoPHP's custom view engine (.vel.php) is a powerful and lightweight solution for building front-end templates. While many directives such as {{ $data }}, {!! $html !!}, @if, @foreach, and layout sections are already functional, the entire directive system is still under active development and refinement.
If you encounter any bugs, unexpected behavior, or missing features in the view system, we welcome your feedback. Please consider:
Emailing us at dev@veltophp.com
Opening a thread on veltophp.com/community
Your reports and suggestions help us improve VeltoPHP for everyone.
This documentation is currently under active development. Some features, syntax, or behaviors described here may still be evolving as VeltoPHP continues to grow.
We truly value your feedback! If you notice outdated sections, unclear explanations, or have suggestions to improve the documentation or framework itself, please don’t hesitate to reach out:
Your insights, ideas, and bug reports are essential to shaping the future of VeltoPHP.
Are you sure?