承接 toanld/modules-inertia 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

toanld/modules-inertia

Composer 安装命令:

composer require toanld/modules-inertia

包简介

Relationship Vue/InertiaJs with modular structure Laravel-Modules

README 文档

README

Software License

The package is designed to be used by Vue/InertiaJs in conjunction with Laravel-Modules

Laravel compatibility

Laravel modules-inertia
6.0-10.x 0.0.x

Installation

Install the package via composer.

composer require toanld/modules-inertia

Config Files

In order to edit the default configuration you may execute:

php artisan vendor:publish --provider="Dongrim\ModulesInertia\ModulesInertiaServiceProvider"

Autoloading

By default, the module classes are not loaded automatically. You can autoload your modules using psr-4. For example:

{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Modules\\": "Modules/",
      "Database\\Factories\\": "database/factories/",
      "Database\\Seeders\\": "database/seeders/"
  }

}

Tip: don't forget to run composer dump-autoload afterwards.

Routing

Module routes must contain middleware in your App\Http\Kernel, as the last item in your web middleware group.

'web' => [
    // ...
    \App\Http\Middleware\HandleInertiaRequests::class,
],

Usage

By default, Vue module files are created in the module directory Resources/Pages

You can change the default directory in config/modules.php

 'Pages/Index' => 'Resources/Pages/Index.vue',
 //...
 'source' => 'Resources/Pages',

For use in Controller

The default value of Inertia::render() in a module has been changed to Inertia::module().

Inertia::render() is still available by default. It can be used outside of modules

  • module_name - real name of the current module
  • file_name - real name of the file (no extension .vue)
  • directory_name - if you have nested display folder structure ( you can specify the file path separating by a dot )

For example:

    public function some_method()
    {
        return Inertia::module('module_name::file_name');
        //
        return Inertia::module('module_name::file_name', ['data'=>'some data']);
        //
        return Inertia::module('module_name::directory_name.file_name', ['data'=>'some data']);
    }

If you use Vue version 2

import Vue from "vue";
import { createInertiaApp, Link } from "@inertiajs/inertia-vue";

createInertiaApp({
    resolve: (name) => {
        let page = null;

        let isModule = name.split("::");
        if (isModule.length > 1) {
            let moduleName = isModule[0];
            let pathToFile = isModule[1];
            // @modules is an alias of the module folder or just specify the path 
            // from the root directory to the folder modules             
            // for example ../../modules
            page = require(`@modules/${moduleName}/${pathToFile}.vue`);
        } else {
            page = require(`./Pages/${name}`);
        }

        return page.default;
    },
    setup({ el, App, props, plugin }) {
        Vue.use(plugin);
       
        new Vue({
            render: (h) => h(App, props),
        }).$mount(el);
    },
});

If you use Vue version 3

import { createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/inertia-vue3";

createInertiaApp({
    resolve: (name) => {
        let page = null;

        let isModule = name.split("::");
        if (isModule.length > 1) {
            let module = isModule[0];
            let pathTo = isModule[1];
            // @modules is an alias of the module folder or just specify the path 
            // from the root directory to the folder modules             
            // for example ../../modules
            page = require(`@modules/${moduleName}/${pathToFile}.vue`);
        } else {
            page = require(`./Pages/${name}`);
        }
        //...
        return page.default;
    },
    setup({ el, App, props, plugin }) {
        createApp({ render: () => h(App, props) })
            .use(plugin)
            .mount(el);
    },
});

Aliases

For the convenience of specifying the path from the root directory to the module directory, you can add alias in webpack.mix.js

const path = require('path')

mix.webpackConfig((webpack) => {
  return {
    resolve: {
       alias: {
         "@modules": path.resolve(__dirname + "/modules"),
       },
    },
  };
});

For the convenience of specifying the path from the root directory to the module directory, you can add alias in vite.config.js

const path = require('path')

export default defineConfig({
  resolve:{
    alias:{
      '@modules' : path.resolve(__dirname + '/modules')
    },
  }
})

Console command

You can run php artisan module:publish-stubs to publish stubs.

And override the generation of default files

After create module

To be VueJS able to find the created module, you need to rebuild the script

npm run dev

Documentation

You'll find installation instructions and full documentation on https://docs.laravelmodules.com/.

Authors

License

The MIT License (MIT). Please see License File for more information.

toanld/modules-inertia 适用场景与选型建议

toanld/modules-inertia 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.02k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2023 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 toanld/modules-inertia 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 14
  • Watchers: 0
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-28