cover-img

How to create your first composer package? 🐘

8 August, 2022

1

1

0

What is Composer?

Composer is a package manager for PHP. As with npm for Node.js and bundler for Ruby, it fills a similar role. It uses a JSON file to capture metadata about the project and the project’s dependencies.

What is Packagist?

Packagist is a centralized Composer repository where anyone can register packages. It aggregates public PHP packages installable with Composer. Packagist currently contains almost 350,000 packages.

Don't have an account?

Navigate to packagist.org and click Create account.

1. Create a project

Create a folder named nullthrows

2. Initialize project as composer package

In this process, you will be asked a number of questions such as the package name, name of the author, the description, minimum stability, the license, etc.
img

This process will generate a composer.json file.

3. Create a file named nullthrows.php with this content in src folder:

4. Add files under autoload in composer.json

5. Create a README.md (optional)

You should provide a brief description of the repository and its functions.

6. Commit the code to GitHub repository

7. Submit package

img

You Did It!

Congratulations, you have published your first Composer package!

tutorial

php

cli

composer

1

1

0

tutorial

php

cli

composer

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.