andrexm/astatine
Composer 安装命令:
composer require andrexm/astatine
包简介
A simple PHP template system inspired by Blade.
README 文档
README
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:
composer require andrexm/astatine
📝 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.
<?php require 'vendor/autoload.php'; use Astatine\Engine; $engine = Engine::getInstance(); $engine::config( "views", // Directory for your template files "cache/views", // Directory for your compiled files (must be writable) ".php" // OPTIONAL: by default, the engine will look for .blade.php files ); // Render a template $engine::render('index', ['name' => 'John Doe']);
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:
mkdir -p cache/views
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.
{{-- Template Inheritance Example --}}
@extends('layouts.master')
@section('title', 'Home Page')
@section('content'):
<h1>Hello, {{ $name }}!</h1>
@if (count($items) > 0):
<ul>
@foreach ($items as $item):
<li>{{ $item }}</li>
@endforeach
</ul>
@else:
<p>No items found.</p>
@endif
@include('partials.footer')
@endsection
Example Layout (templates/layouts/master.at.php)
<!DOCTYPE html> <html> <head> <title>@yield('title')</title> </head> <body> <header> {{-- Site header --}} </header> <main> @yield('content') </main> <footer> @yield('footer') </footer> </body> </html>
🧠 Template Syntax Overview
Astatine uses @ prefixed directives and {{ }} for echoed variables.
Control Structures
@if (condition):
...
@elseif (condition):
...
@else:
...
@endif
@foreach ($array as $key => $value):
...
@foreach ($array as $value):
...
@endforeach
@for ($i = 0; $i < 10; $i++):
...
@endfor
@while (condition):
...
@endwhile
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.
andrexm/astatine 适用场景与选型建议
andrexm/astatine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 andrexm/astatine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 andrexm/astatine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-14