madan2056/yapptheme 问题修复 & 功能扩展

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

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

madan2056/yapptheme

Composer 安装命令:

composer require madan2056/yapptheme

包简介

Theme support for Laravel 8/9 with assets, theme extends etc.

README 文档

README

Inspired by bigecko/laravel-theme. Themes are stored inside default laravel's resources folder

Requirements

This package requires PHP 7.3 or event 8.* and Laravel 8 or 9.

Currently, supported only for webpack with laravel-mix.

Installation

You can install this package via composer using:

composer require yaap/theme

or manually add line to composer.json

{
  "require": {
    "yaap/theme": "^4.0"
  }
}

Optionally, publish config using artisan CLI (if you want to overwrite default config).

php artisan vendor:publish --provider="YAAP\Theme\ThemeServiceProvider"

Configuration

Package config

return [

    /*
    |--------------------------------------------------------------------------
    | Path to directory with themes
    |--------------------------------------------------------------------------
    |
    | The directory with your themes.
    |
    */

    'path' => base_path('themes'),

    /*
    |--------------------------------------------------------------------------
    | Path to directory with assets build
    |--------------------------------------------------------------------------
    |
    | The directory with assets build in public directory.
    |
    */

    'assets_path' => 'themes',

    /*
    |--------------------------------------------------------------------------
    | A pieces of theme collections
    |--------------------------------------------------------------------------
    |
    | Inside a theme path we need to set up directories to
    | keep "layouts", "assets" and "partials".
    |
    */

    'containerDir' => [
        'assets' => 'assets',
        'lang' => 'lang',
        'layout' => 'layouts',
        'partial' => 'partials',
        'view' => 'views',
    ],
];

Theme config

Config in theme folder

return [

    /*
    |--------------------------------------------------------------------------
    | Theme name
    |--------------------------------------------------------------------------
    |
    | Use in assets publishing etc.
    |
    */

    'name' => '%theme_name%',

    /*
    |--------------------------------------------------------------------------
    | Inherit from another theme
    |--------------------------------------------------------------------------
    |
    | Set up inherit from another if the file is not exists.
    |
    */

    'inherit' => null,

];

Usage

Create theme with artisan CLI

The first time you have to create theme default structure, using the artisan command:

php artisan theme:create default

In order to seed webpack.mix.js with custom rules add --with-mix option

php artisan theme:create default --with-mix

To delete an existing theme, use the command:

php artisan theme:destroy default

Structure

Here is an example of the folder structure of project with theme

project-root
├── app/
<...>
├── public/
|   ├── index.php
|   └── themes/
|       └── default/
|           ├── js/
|           |   └── app.js
|           ├── css/
|           |   └── styles.css
|           └── images/
|               └── icon.png
├── resources/
<...>
├── themes/
|   ├── default/
|   |   ├── assets/        
|   |   ├── lang/        
|   |   ├── layouts/
|   |   ├── partials/
|   |   ├── views/
|   |   |   └── hello.blade.php
|   |   └── config.php
|   ├── admin/
|   ├── views/
|       ├── emails/
|       |   └── notify.blade.php
|       └── hello.blade.php

Init theme

Theme::init($name)

This will add to views find path:

  • themes/{$name}
  • themes/{$name}/views

Lang files will be added as well:

  • themes/{$name}/lang

Making view

View::make('hello');
View::make('emails.notify');

Assets

Use laravel mix for assets.

In header

<link rel="stylesheet" href="{{ mix('/themes/default/css/app.min.css') }}"/>

and in footer

<script type="text/javascript" src="{{ mix('/themes/default/js/app.min.js') }}"></script>

Blade templates

@extends('layouts.master')

@include('partials.header')

@section('content')
    <section id="main">
        <h1>HOME</h1>
    </section>
@stop

@include('partials.footer')

Fallback capability

You still able to use default View::make('emails.notify') which is stored outside the themes directory.

Can I hire you guys?

Yes! Say hi: hello@hexide-digital.com

We will be happy to work with you! Other work we’ve done

Follow us

Stay up to date with the latest Vuestic news! Follow us on LinkedIn or Facebook

License

MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固