simpsons / composermode
A custom module for Magento 2
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:magento2-module
Requires
- php: ^8.1
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0
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
-
Create Module Structure
- Create the necessary directories and files for your Magento 2 module.
-
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\\": "" } } }
- Create a
-
Create Module Files
- Create
registration.php
andmodule.xml
files as required by Magento 2.
- Create
Installing the Module via Composer
- Install the Module
- Use the following command to install the module:
composer require simpsons/composermode dev-main
- Use the following command to install the module:
Requirements
- PHP 8.1 is required for compatibility.
Uploading Your Package to Packagist.org
-
Create an Account on Packagist.org
- Visit Packagist.org and sign up for a new account.
- Verify your email address to activate the account.
-
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
-
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.
-
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".
- Payload URL:
- 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.