Create package and release to packagist with composer and github


In this section, we will create a PHP package in GitHub and release it into

  1. Create a new folder, which is the name will become your package name. Example calculator.
  2. Create a new folder inside calculator, with name src. Your file should be stored /li>
  3. Create file Calculator.php with class Calculator, like below

  4. Create composer.json in your top folder (calculator/composer.json)
  5. With composer init or manually like below

    The important things, your namespace (redzjovi\calculator) in folder src should be autoloaded.
  6. Run composer update. Then create folder test and file test.php to test the class.
  7. After test complete, create, commit and push to your GitHub.

  8. The url git should be located inĀ
  9. Go to, create account and try to submit package.
  10. If your package is accepted, it will be show like this.
  11. The last is set auto update package on every push with Webhooks GitHub. Go to settings -> integration & services, add services packagist.Add user, token from packagist, then submit.

Reference :


Please enter your name here
Please enter your comment!