abitofmaya/blade-renderer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

abitofmaya/blade-renderer

最新稳定版本:v1.0.0

Composer 安装命令:

composer require abitofmaya/blade-renderer

包简介

Standalone Blade Template Renderer

README 文档

README

Blade Renderer is a simple wrapper around illuminate/view, the package that powers the Blade templating engine used with Laravel.

This package allows Blade's powerful and expressive syntax to be uesd in any PHP project without needing to install the full Laravel framework. It abstracts the setup and configuration needed to render blade templates, making it more accessible and straightforward for use in non-Laravel projects.

It uses a similar directory structure as Laravel for organizing views and caches.
The views are stored at the resources/views directory and the view caches at storage/framework/views.

Usage

Blade Renderer can be used in either of the following two ways.

As a Standalone Project

You can use Blade Renderer to quickly start a new standalone project. To do this, follow these steps:

  1. Create a New Project

    Run the following command in your terminal to create a new project.

    composer create-project abitofmaya/blade-renderer <project-name>
  2. Run the Development Server

    Navigate into the project directory and start a PHP development server by running:

    php -S localhost:8000 -t public

Example

  • Edit src/app.php with the following contents:

    <?php
    
    use abitofmaya\BladeRenderer\BladeRenderer;
    
    $renderer = new BladeRenderer();
    
    $posts = [
        [
            'title' => 'The Art of Minimalism: Living with Less',
            'description' => 'Learn how to declutter your life and find happiness in simplicity.'
        ],
        [
            'title' => 'The Future of Technology',
            'description' => 'Dive into the technological advancements shaping the future.'
        ]
    ];
    
    echo $renderer->view(view: 'bladeRenderer', data: ['posts' => $posts]);
  • Create bladeRenderer.blade.php in resources/views directory with the following contents.

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8" />
            <meta
                name="viewport"
                content="width=device-width, initial-scale=1.0"
            />
            <title>Blade Renderer</title>
        </head>
    
        <body>
            @foreach($posts as $post)
            <div>
                <p><strong>Title</strong>: {{ $post['title'] }}</p>
                <p><strong>Description</strong>: {{ $post['description'] }}</p>
            </div>
            @endforeach
        </body>
    </html>

As a Dependency in an Existing Project

If you have an existing PHP project and want to add Blade templating capabilities, you can include Blade Renderer as a project dependency. Here's how:

  1. Install the Package

    Run the following command in your terminal to install Blade Renderer.

    composer require abitofmaya/blade-renderer
  2. Setup Directory Structure

    After installation, you will need to manually set up the directory structure for the views and caches. Create the following directories:

    • resources/views for storing your Blade templates.
    • storage/framework/views for storing view caches.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固