gfd6th/laravel-mobile-first 问题修复 & 功能扩展

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

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

gfd6th/laravel-mobile-first

Composer 安装命令:

composer require gfd6th/laravel-mobile-first

包简介

Support implement mobile-first principle for your Laravel application.

README 文档

README

Laravel Mobile First


Latest version Build status Quantity score StyleCI Total download License

About it

A package support you implementing mobile-first principle base on Jenssegers Agent.

Installation

Require Laravel Mobile First using Composer:

composer require vxm/laravel-mobile-first

After require, you need to publish the config-file with:

php artisan vendor:publish --provider="VXM\MobileFirst\MobileFirstServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    /**
     * Your mobile site use to redirect when user not using desktop device.
     * Note: it only affect when you registered `VXM\MobileFirst\MobileRedirect` middleware.
     */
    'mobile_url' => 'https://m.yoursite.com',

    /**
     * Keep url path when redirect to mobile url (ex: https://yoursite.com/abc to https://m.yoursite.com/abc).
     */
    'keep_url_path' => true,

    /**
     * HTTP status code will be set when redirect to mobile url.
     */
    'redirect_status_code' => 301,

    /**
     * HTTP request method should be redirect to mobile url.
     */
    'redirect_methods' => ['OPTIONS', 'GET'],

    /**
     * Enable auto switch view by device type.
     * When enabled, the system auto switch view to compatible view (sub-view) by user device type (ex: 'index.blade.php' => 'mobile/index.blade.php'),
     * compatible view will be find on `device_sub_dirs`. If not found, not affect.
     */
    'auto_switch_view_by_device' => false,

    /**
     * An array with key is device type and value is sub dir of it. Use to switch view to compatible view (sub-view) by user device type.
     */
    'device_sub_dirs' => [
        //'phone' => 'phone', // switch when device is phone.
        //'tablet' => 'tablet', // switch when device is tablet.
        //'android' => 'android', // switch when device os is android.
        //'ios' => 'ios', // switch when device os is ios.
        'mobile' => 'mobile', // switch when device is tablet or phone.
    ],
];

Usage

This package provides you two features:

Mobile redirect

You need setup your mobile site url in your mobilefirst config file:

    'mobile_url' => 'https://m.yoursite.com',

Now add middleware:

// app/Http/Kernel.php

protected $middleware = [
       ...
       \VXM\MobileFirst\MobileRedirect::class,
],

Auto switch view

This feature is disabled by default, you need to enabled it in mobilefirst config file:

    'auto_switch_view_by_device' => true,

It is a way to replace a set of views with another by user device without the need of touching the original view rendering code. You can use it to systematically change the look and feel of an application depend on user device. For example, when call view('about'), you will be rendering the view file resources/views/about.blade.php, if user use mobile device, the view file resources/views/mobile/about.blade.php will be rendered, instead.

The device_sub_dirs governs how view files should be replaced by user device. It takes an array of key-value pairs, where the keys are the device types and the values are the corresponding view sub-directory. The replacement is based on user device: if user device match with any key in the device_sub_dirs array, a view path will be added with the corresponding sub-directory value. Using the above configuration example, when user using mobile device because it match the key mobile, a view path will be added mobile look like resources/views/mobile/about.blade.php. Of course you can change the value or add more cases:

    'device_sub_dirs' => [
        'ios' => 'apple', // switch when device os is ios.
        'mobile' => 'mobile', // switch when device is tablet or phone.
    ],

The above configuration if user using ios, the view path will be added apple.

gfd6th/laravel-mobile-first 适用场景与选型建议

gfd6th/laravel-mobile-first 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「vxm」 「laravel-mobile-first」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gfd6th/laravel-mobile-first 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gfd6th/laravel-mobile-first 我们能提供哪些服务?
定制开发 / 二次开发

基于 gfd6th/laravel-mobile-first 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-26