Launchpad
Launchpad
Launchpad
  • Introduction
  • General
    • Installation
    • Creating a subscriber
    • Contributing
  • Tutorials
    • Beginner documentation
      • Beginner handbook
        • Creating subscribers
        • Wiring subscribers
        • Installing local environment
        • Adding front-end
        • Building the plugin
      • Plugin life circle
        • Activation
        • Deactivation
        • Uninstall
    • Starting with the framework
    • Migrating to Launchpad
    • Notions
      • Framework concepts
        • Inversion of control
        • Subscribers
        • Dispatcher
      • Good practices
        • Hooks
          • Preventing magic constants
          • Decouple features
          • Sanitize filters output
      • Testing
        • Organize tests
  • CLI
    • Commands
    • Creating a command
  • Testing
    • Unit test
    • Fixtures
    • Integration test
  • Container
    • Architecture
    • Parameters
    • Providers
    • Auto wiring
    • Manual wiring
    • Activation/Deactivation
    • Inflectors
  • Modules
    • Definition
    • Listing
      • Action Scheduler
      • BerlinDB
      • Bus
      • Options
      • Renderer
      • Logger
      • Uninstaller
      • Filesystem
      • Front-end
      • Hook extractor
    • Creating a module
Powered by GitBook
On this page
  • Minimal structure
  • Adding some logic
  • Clean up the package
  1. Modules

Creating a module

Minimal structure

Simple modules that are here to install a library don't require more than a composer.json file.

All field Launchpad uses to install the library are inside "meta" / "Launchpad" field from the JSON.

If you need to install a libary then you need to add the field "libraries" and put the library and its version as value:

{

   "meta": {
      "launchpad": {
         "libraries": {
            "my-library": "version"
         }
      }
   }
}

Adding some logic

Sometimes you will need to execute more actions than adding a library.

In this case you will have to create a specific command that will run when the module is required into the project.

Creating the command

The install command is a simple CLI and to create it that would be as easy as for a regular commmand.

Registering the command

Once your command is created and the service provider linked to it too.

You can then register it to the module for that you will have to add two new fields:

  • "command": This will be the name of the command to execute.

  • "provider": This will be the full name of the provider to add to the CLI when installing.

{

   "meta": {
      "launchpad": {
         "command": "install",
         "provider": "MyProvider",
      }
   }
}

Clean up the package

In most cases you don't need anymore the installation package.

That's why you can set an automatic clean up from the installation package when the installation is finished.

For that you need to add "clean" to true inside the composer.json:

{

   "meta": {
      "launchpad": {
         "libraries": {
            "my-library": "version",
            "clean": true
         }
      }
   }
}
PreviousHook extractor

Last updated 2 years ago

For that you can check the about that.

page of the wiki