Code Monkey home page Code Monkey logo

blade's Introduction

cc blade

說明

此專案給後端是 laravel 前端工程師 or 網頁設計師 使用

不需要 composer install, vendor 打包進專案裡面,預防 前端工程師 or 網頁設計師 不會使用

使用 語意化版本 2.0

使用方式

依照 創建 blade 目錄 生成 route

在 resources/views 創建 xxx.blade.php 網址將會是 http://localhost:8088/xxx

在 resources/views 創建 blog/xxx.blade.php 網址將會是 http://localhost:8088/blog/xxx

如果 使用資料夾模式打開

網址將會是 http://localhost/you dir/xxx, http://localhost/you dir/blog/xxx

如果 Apache 沒有設定 .htaccess

沒有使用 npm run serve

網址將會是 http://localhost/index.php/you dir/xxx, http://localhost/index.php/you dir/blog/xxx

有使用 npm run serve

或者 http://localhost:8088/index.php/xxx, http://localhost/index.php/blog/xxx

建議使用方式

使用 npm run serve

建議設定

Apache 設定 AllowOverride All

<Directory "you path">
        Options Indexes FollowSymLinks MultiViews ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

快速連結

介紹 網址
laravel-mix webpack 操作說明 laravel-mix
blade 樣板引擎說明 laravel-blade

更新說明

更新說明

clone 注意事項

請刪除以下檔案

.git
doc/
composer.json
composer.lock
readme.md

發布檔案前注意事項

只要上傳以下檔案

  app/
  public/
  resources/views/
        ../.htaccess
        ../index.html
  storage/
  vendor/
  index.php
  .htaccess
  robots.txt

特別要注意 storage/ 要改權限成 777

資料結構說明

資料夾 說明
app 主程式
public min.js、min.css、img...etc
storage 自動產生 Html,快取
vendor 核心程式
resources
  • - style、js、img 原始碼
  • - views: blade.php

require package

套件名稱 作用 網址
symfony/http-foundation http-foundation 套件 https://github.com/symfony/http-foundation
symfony/var-dumper dd指令 https://github.com/symfony/var-dumper
filp/whoops 錯誤收集 https://github.com/filp/whoops
intervention/image 圖像處理 https://github.com/Intervention/image

如何載入 style、js、img

    <link href="{{ asset('styles/bootstrap.min.css') }}" rel="stylesheet">
    <script src="{{ asset('scripts/bootstrap.min.js') }}"></script>
    <img src="{{ asset('images/icon.png') }}" />

如何使用連結

    <a href="{{ url('/') }}">首頁</a>

Ajax

    $.get('{{ url('/test') }}', {}, function(data){
        console.log(data);
    });

Request

url_is(url, Class Name)

方法一 url_is("project*", "active") 只要網址開頭是 project 都會給于 "active"

<li><a href="{{ url("project/index") }}" class="{{ url_is("project*", "active") }}">index</a></li>

方法二 url_is("project/*", "active") 只有網址是 project/ 下面的檔案才會給于 "active"

<li><a href="{{ url("project/index") }}" class="{{ url_is("project*", "active") }}">index</a></li>

方法三 url_is("project/contact", "active") 只有網址是 project/contact 才會給于 "active"

<li><a href="{{ url("project/contact") }}" class="{{ url_is("project/contact", "active") }}">contact</a></li>

imageHelper

imageHelper(路徑, 格式, 寬, 高);

除了路徑 以外皆可為空

使用方式如下:

轉換格式跟縮圖

<img src="{{ imageHelper('images/index.jpg', 'webp', 100, 100) }}" alt="">

轉換格式

<img src="{{ imageHelper('images/index.jpg', 'webp') }}" alt="">

縮圖

<img src="{{ imageHelper('images/index.jpg', null, 100, 100) }}" alt="">

依寬度等比例縮圖

<img src="{{ imageHelper('images/index.jpg', null, 100) }}" alt="">

依高度等比例縮圖 跟轉換格式

<img src="{{ imageHelper('images/index.jpg', 'webp', null, 100) }}" alt="">

Enums 列舉

在 app\Enums 創建 新的 php class

<?php namespace App\Enums;

use App\Enums\Enum;

 class Test extends Enum
{
    public function fill()
    {
        return [
            'test' => 1,
            'test2' => ['a' => 1, 'b' => 2],
            'test3' => [1, 2, 3, 4]
        ];
    }
}

在 blade 引入

    @inject('test', '\App\Enums\Test')
    ...
    
    @foreach($test as $item)
    
    @endforeach

asset

asset 使用外部資源

如果 webpack.mix.js 有加入

if (mix.inProduction()) {
    mix.setPublicPath(path.resolve('./'));
    mix.version();
}

會自動 找尋 mix-manifest.json 內容更新版本號碼

輸出成 html

blade 輸出成 html 網頁介面

網頁介面 網址是 http://localhost/_setting

縮圖

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.