Download the PHP package andrexm/astatine without Composer
On this page you can find all versions of the php package andrexm/astatine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrexm/astatine
More information about andrexm/astatine
Files in andrexm/astatine
Package astatine
Short Description A simple PHP template system inspired by Blade.
License MIT
Informations about the package astatine
Astatine Template Engine
A very simple and lightweight PHP template engine with a syntax inspired by Laravel's Blade. It's designed to be easy to use and integrate into your PHP projects without unnecessary complexity.
✨ Features
-
Clean Syntax: Uses
@directives and{{ }}echo statements, familiar to Laravel developers. -
Template Inheritance: Supports
@extends,@section, and@yieldfor building layouts. -
Includes: Reuse template partials with the
@includedirective. -
Control Structures: Provides convenient directives like
@if,@else,@foreach,@while, etc. -
Echoing Data: Automatically escapes output with
{{ $variable }}for security. Use{!! $variable !!}for unescaped data. - Lightweight & Fast: Compiles templates into plain PHP code for optimal performance.
🚀 Installation
You can install the package via Composer:
📝 Basic Usage
Here's a quick example of how to use Astatine.
Configuration
First, you need to set up the engine with paths to your template directories.
See examples/basics.php file. Also, as mentioned in the example above, the engine will look
for .blade.php files, in order to allow you to use extensions for syntax highlighting in Blade. If
you want to change that, just set the $extension to ".php" (as in the example above) or
other stuff.
Also, since you should provide a cache directory, you have to first create that directory:
Example Template (templates/index.at.php)
Here is an example to show how similar it is to Blade. Actually, there is a single difference you
should be aware of: commands that define blocks must end with a :, like @if(...): ... @endif.
Follow the example below to understand better.
Example Layout (templates/layouts/master.at.php)
🧠 Template Syntax Overview
Astatine uses @ prefixed directives and {{ }} for echoed variables.
Control Structures
Template Inheritance
-
@extends('layout.name'): Specifies the layout the template inherits from. -
@section('name'): ... @endsection: Defines a section block. @yield('name'): In a layout, displays the content of a section.
Including Partials
@include('path.to.partial'): Includes another template. Partials always have access to parent data.
Comments
{{-- This is a comment --}}: Comments are not rendered in the final HTML.
Echoing Data
-
{{ $variable }}: Echoes escaped data (prevents XSS). {!! $variable !!}: Echoes unescaped data (use carefully!).
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository.
-
Create your feature branch (
git checkout -b feature/amazing-feature). -
Commit your changes (
git commit -m 'Add some amazing feature'). -
Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
📄 License
The MIT License (MIT). Please see License File for more information.