定制 caiquebispo/blade-slim 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

caiquebispo/blade-slim

最新稳定版本:1.0.2

Composer 安装命令:

composer require caiquebispo/blade-slim

包简介

Pacote para usar Blade (Laravel) no Slim Framework

README 文档

README

Integration of Blade Template Engine with Slim Framework

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

A package that seamlessly integrates Laravel’s Blade templating engine with the Slim Framework, providing a smooth development experience with full Blade features in Slim applications.

Installation

Install via Composer:

composer require caiquebispo/blade-slim

Quick Setup

Configure Blade in your Slim application:

use BladeSlim\Blade;
use Slim\Factory\AppFactory;

$app = AppFactory::create();

// Blade Configuration
$blade = new Blade(
    __DIR__ . '/../resources/views', // Views directory
    __DIR__ . '/../storage/cache',   // Cache directory
    $app->getResponseFactory()->createResponse() // Response prototype
);

Create your first view in resources/views/home.blade.php and make sure the storage/cache folder is writable:

<!DOCTYPE html>
<html>
<head>
    <title>{{ $title }}</title>
</head>
<body>
    <h1>Welcome to {{ $appName }}!</h1>
</body>
</html>

Use it in a route:

$app->get('/', function () {
    return view('home', [
        'title' => 'Home Page',
        'appName' => 'My Slim App'
    ]);
});

Key Features

Global view() Function

Automatically returns a ready PSR-7 response.

Supports data, status codes, and headers:

return view('error', ['message' => 'Not Found'], 404);

Full Blade Support

  • Template inheritance (@extends)
  • Sections (@section, @yield)
  • Components (@component)
  • Custom directives
  • Sub-view inclusion (@include)

Flexible Configuration

  • Multiple view paths
  • Optional caching
  • Integration with Slim's DI container

Advanced Usage

Custom Directives

$blade->getFactory()->directive('datetime', function ($expression) {
    return "<?php echo ($expression)->format('d/m/Y H:i'); ?>";
});

Contributing

Contributions are welcome! Follow these steps:

  1. Fork the project
  2. Create your branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.

📧 Contact

Caique Bispo - caiquebispodanet86@gmail.com

Project Link: https://github.com/caiquebispo/blade-slim

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-19