Giter VIP home page Giter VIP logo

elapse-annals / laravel-plus Goto Github PK

View Code? Open in Web Editor NEW
49.0 3.0 9.0 14.74 MB

Based on Laravel transformation and expansion, more convenient for practical business use

Home Page: https://elapseannals.github.io/LaravelPlus/

License: Apache License 2.0

PHP 61.70% Shell 0.13% Blade 32.57% Dockerfile 1.00% Vue 4.61%
laravel-plus laravel laravel-framework php php-framework react-php transformers laravel-vue laravelplus

laravel-plus's Introduction

English | 中文

plus

php-badge laravel-badge Build Status License composer.lock

介绍

LaravelPlus 基于 Laravel 增加部分软件包初始安装和进行业务使用功能改动,来创建一个开箱即用的应用.

目的

  • 增加基于模型 CURD 生成工具
  • 自动 Laravel 与 Vue/Element UI 基于基础模型的代码生成器。
  • 环境配置切换

运行环境要求

  • PHP
  • composer
  • MySQL | PgSQL

项目使用

0.配置镜像

配置 composer aliyun 镜像

$ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

1.下载项目

$ git clone https://github.com/ElapseAnnals/laravel-plus.git

2.创建新项目

//  A.在当前目录运行自动复制脚本 ( 推荐)
// YourProject 需要创建的项目名
$ php LaravelPlus/create YourProject

3.新项目初始化

$ cd YourProject //  进入 YourProject 项目中
$ composer update
$ php artisan make:framework init --init
4。本地服务开启
php artisan serve

Tips:

更新 YourProject 项目(插件有改动时在上级目录中使用)
php LaravelPlus/update YourProject

功能使用说明

创建分层脚本和资源映射:想法来源

framework 脚本创建内容:

  • Controller, Service, Repository 等文件和对应关联关系
  • Route 资源路由增加
  • Controller 中资源类型代码和模型数据处理

模型生成

php artisan code:models --table=table_name   // 指定表
php artisan code:models --connection=mysql  // 指定数据库连接
php artisan code:models --connection=mysql --table=table_name   // 指定连接和指定表

使用 framework 功能创建 CURL(Tmpls 是对应模型复数名称)

 $ php artisan make:framework Tmpls  // 创建分层结构(推荐)
 $ php artisan make:framework Tmpls --D // 删除分层结构 
  $ php artisan make:framework Tmpls --F // 强制生成分层结构 

效果图: image

Tips:

  • 注意文件被其它服务占用问题,可进行重启尝试 (Failed to clear cache. Make sure you have the appropriate permissions.)
  • 使用导出需要在 web.php 中 export 注册路由
热切换配置使用(config/dynamic/)

在 .env 中设置 ENABLE_HOT_SWITCHING=true 后,会在 AppServiceProvider 进行 dynamic 映射

使用方式:

<?php
$env = config('dynamic.env');

dynamic 目录文件说明

  • production 生产环境 (必须配置)
  • develop 开发环境 (必须配置,以下配置继承 develop 配置)
    • test 测试环境
    • local 本地环境
    • simulation 仿真环境

Tips:

  1. .env 配置 DYNAMIC_IS_STRICT 控制热配是否严格模式(默认 false 关闭)
    • 严格模式下不会继承 production/develop,完全采用当前环境配置
  2. 默认在继承基础上有重复属性,会覆盖继承项
  3. 继承基础特有属性会被携带至当前配置
  4. config/dynamic.php 为 IDEA 提示文件,使用空 key 即可

优化默认路由中闭包

  • 路由中禁止使用闭包,如有需要请在 ClosureController 中注册
缓存清理
  • php artisan optimize:clear // (慎用)
    • php artisan view:clear
    • php artisan cache:clear // 应用程序缓存清理(慎用- 会清理 config.cache 中启用缓存(file/db/redis 等))
    • php artisan route:cache
    • php artisan config:clear
    • php artisan clear-compiled // 清理编译 php artisan debug:clear

性能优化(只建议生产环境使用)

  • php artisan optimize // 类映射加载优化(该命令会自动缓存 config/route)
    • php artisan config:cache // 配置缓存
    • php artisan route:cache // 路由
  • php artisan view:cache // 视图缓存
  • composer dump-autoload --optimize //
  • 开启 OpCache
    $ sudo vim /etc/php/7.2/fpm/php.ini
    // set opcache.enable=1
    // ...
    $ sudo service php5.6-fpm restart
    $ sudo service nginx restart

前端处理

资源构建
npm run dev    // 本地开发,开启 debug 模式
npm run prod    // 线上部署(进行压缩资源)

npm run watch   // 监视编译(开发时启用)
模板使用

使用 mixin 注入 vue 组件

<script>
    var js_data = @json($js_data);
    var mixinSlot = {
        data: {},
        methods: {}
    }
</script>
<script type="text/javascript" src="{{asset('js/app.js')}}"></script>
路由 web/api 使用区别和场景

web 经过权限,csrf 等中间件和 Session api token 维护使用 auth:api 中间件或 barryvdh/laravel-cors 若非单纯 api ,建议使用 web


-推荐扩展

Stargazers over time

Stargazers over time

laravel-plus's People

Contributors

benhuang1024 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.