simpsons/composermode

A custom module for Magento 2

dev-main 2024-07-08 14:44 UTC

This package is auto-updated.

Last update: 2025-06-23 12:30:42 UTC


README

Introduction

This guide provides steps to create a simple module, install it via Composer in a third-party or your own Magento 2 project, and upload the package to Packagist.org while connecting it with GitHub.

Creating a Simple Module

  1. Create Module Structure

    • Create the necessary directories and files for your Magento 2 module.
  2. Define composer.json

    • Create a composer.json file in the root directory of your module with the following content:
      {
        "name": "simpsons/composermode",
        "description": "A simple Magento 2 module",
        "require": {
          "php": "^8.1"
        },
        "type": "magento2-module",
        "version": "1.0.0",
        "autoload": {
          "files": [
            "registration.php"
          ],
          "psr-4": {
            "Simpsons\\ComposerModule\\": ""
          }
        }
      }
  3. Create Module Files

    • Create registration.php and module.xml files as required by Magento 2.

Installing the Module via Composer

  1. Install the Module
    • Use the following command to install the module:
      composer require simpsons/composermode dev-main

Requirements

  • PHP 8.1 is required for compatibility.

Uploading Your Package to Packagist.org

  1. Create an Account on Packagist.org

    • Visit Packagist.org and sign up for a new account.
    • Verify your email address to activate the account.
  2. Submit Your Package

    • Once logged in, click on "Submit" in the top menu.
    • Enter the URL of your GitHub repository and click "Check".
    • After validation, submit your package.

Connecting GitHub with Packagist

  1. Link Your GitHub Account

    • Go to your Packagist profile and click on "Settings".
    • Click "Link GitHub account" and follow the instructions to authorize Packagist to access your GitHub repositories.
  2. Automate Package Updates

    • In your GitHub repository, navigate to "Settings" > "Webhooks".
    • Add a new webhook with the following details:
      • Payload URL: https://packagist.org/api/github
      • Content type: application/json
      • Events: Select "Just the push event".
    • Save the webhook.

Summary

Following the steps above, you can create a simple Magento 2 module, install it using Composer, and manage your package on Packagist.org. Ensure your module meets the PHP 8.1 requirement for compatibility.