Coder Social home page Coder Social logo

simple-module's Introduction

The Simple Module For Laravel

Testing PHPStan Validate Composer

A very simple modular system for Laravel.
Enjoy!

Installation

Execute the following composer command.

composer require takemo101/simple-module

Publish the config

Publish the config with the following artisan command.

php artisan vendor:publish --tag="simple-module"

About composer.json

Create a'module' directory in the directory where composer.json is located.
Then set the path of the directory you added to composer.json.

    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Module\\": "module/", <- added
            ...
        }
    },
    ...

How to use

You can execute the command as below.

1. Create a module

Create a module file in the module directory

php artisan simple-module:create ModuleName

or

php artisan simple-module:create ModuleName --namespace=OtherModuleNamespace

2. module install

Execute the process of the install method of Module.php of the created module file.

php artisan simple-module:install

or

php artisan simple-module:install --module=ModuleName

3. module uninstall

Execute the process of uninstall method of Module.php of the created module file.

php artisan simple-module:uninstall

or

php artisan simple-module:uninstall --module=ModuleName

4. module update

Only update the dependent packages of the created module file.

php artisan simple-module:update

or

php artisan simple-module:update --module=ModuleName

How to set the module file

The following is a setting example of Module.php.

<?php

namespace Other\Sync;

use Takemo101\SimpleModule\Support\ {
    InstallerInterface,
    ServiceProvider,
};

/**
 * Module files are Laravel's service provider, so you can use them in the same way.
 */
class Module extends ServiceProvider implements InstallerInterface
{
    public function register()
    {
        //
    }

    public function boot()
    {
        //
    }

    /**
     * module install process
     *
     * @return void
     */
    public function install()
    {
        // Write the process when installing the module.
    }

    /**
     * module uninstall process
     *
     * @return void
     */
    public function uninstall()
    {
        // Write the process when uninstalling the module.
    }

    /**
     * install packages
     *
     * Set the package string to the key of the associative array.
     * For the value of the associative array, set whether to uninstall or not with boolean type.
     *
     * @return boolean[]
     */
    public function packages(): array
    {
        return [
            'bensampo/laravel-enum' => true, // It is deleted at the same time as uninstalling
            'jeroennoten/laravel-adminlte' => false, // Not deleted even if uninstalled
        ];
    }
}

simple-module's People

Contributors

hayama-kei avatar takemo101 avatar

Stargazers

 avatar

Watchers

 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.